Merge pull request #289 from NQNStudios/cboe
This commit is contained in:
@@ -35,6 +35,7 @@ extern sf::Texture bg_gworld;
|
|||||||
const short cDialog::BG_DARK = 5, cDialog::BG_LIGHT = 16;
|
const short cDialog::BG_DARK = 5, cDialog::BG_LIGHT = 16;
|
||||||
short cDialog::defaultBackground = cDialog::BG_DARK;
|
short cDialog::defaultBackground = cDialog::BG_DARK;
|
||||||
cDialog* cDialog::topWindow = nullptr;
|
cDialog* cDialog::topWindow = nullptr;
|
||||||
|
void (*cDialog::redraw_everything)() = nullptr;
|
||||||
|
|
||||||
std::string cDialog::generateRandomString(){
|
std::string cDialog::generateRandomString(){
|
||||||
// Not bothering to seed, because it doesn't actually matter if it's truly random.
|
// Not bothering to seed, because it doesn't actually matter if it's truly random.
|
||||||
@@ -517,7 +518,9 @@ void cDialog::run(std::function<void(cDialog&)> onopen){
|
|||||||
win.create(sf::VideoMode(1,1),"");
|
win.create(sf::VideoMode(1,1),"");
|
||||||
win.close();
|
win.close();
|
||||||
win.create(sf::VideoMode(winRect.width(), winRect.height()), "Dialog", sf::Style::Titlebar);
|
win.create(sf::VideoMode(winRect.width(), winRect.height()), "Dialog", sf::Style::Titlebar);
|
||||||
win.setPosition({parentPos.x + int(parentSz.x - winRect.width()) / 2, parentPos.y + int(parentSz.y - winRect.height()) / 2});
|
winLastX = parentPos.x + int(parentSz.x - winRect.width()) / 2;
|
||||||
|
winLastY = parentPos.y + int(parentSz.y - winRect.height()) / 2;
|
||||||
|
win.setPosition({winLastX, winLastY});
|
||||||
draw();
|
draw();
|
||||||
makeFrontWindow(parent ? parent-> win : mainPtr);
|
makeFrontWindow(parent ? parent-> win : mainPtr);
|
||||||
makeFrontWindow(win);
|
makeFrontWindow(win);
|
||||||
@@ -690,6 +693,15 @@ void cDialog::handle_one_event(const sf::Event& currentEvent) {
|
|||||||
break;
|
break;
|
||||||
case sf::Event::GainedFocus:
|
case sf::Event::GainedFocus:
|
||||||
case sf::Event::MouseMoved:
|
case sf::Event::MouseMoved:
|
||||||
|
// Did the window move, potentially dirtying the canvas below it?
|
||||||
|
auto winPosition = win.getPosition();
|
||||||
|
if (winLastX != winPosition.x || winLastY != winPosition.y) {
|
||||||
|
if (redraw_everything != NULL)
|
||||||
|
redraw_everything();
|
||||||
|
}
|
||||||
|
winLastX = winPosition.x;
|
||||||
|
winLastY = winPosition.y;
|
||||||
|
|
||||||
bool inField = false;
|
bool inField = false;
|
||||||
for(auto& ctrl : controls) {
|
for(auto& ctrl : controls) {
|
||||||
if(ctrl.second->getType() == CTRL_FIELD && ctrl.second->getBounds().contains(currentEvent.mouseMove.x, currentEvent.mouseMove.y)) {
|
if(ctrl.second->getType() == CTRL_FIELD && ctrl.second->getBounds().contains(currentEvent.mouseMove.x, currentEvent.mouseMove.y)) {
|
||||||
|
@@ -41,6 +41,8 @@ class cDialog {
|
|||||||
short bg;
|
short bg;
|
||||||
sf::Color defTextClr;
|
sf::Color defTextClr;
|
||||||
sf::RenderWindow win;
|
sf::RenderWindow win;
|
||||||
|
int winLastX=-1;
|
||||||
|
int winLastY=-1;
|
||||||
std::string currentFocus;
|
std::string currentFocus;
|
||||||
cDialog* parent;
|
cDialog* parent;
|
||||||
std::string generateRandomString();
|
std::string generateRandomString();
|
||||||
@@ -49,6 +51,7 @@ class cDialog {
|
|||||||
std::vector<std::pair<std::string,cTextField*>> tabOrder;
|
std::vector<std::pair<std::string,cTextField*>> tabOrder;
|
||||||
static cDialog* topWindow; // Tracks the frontmost dialog.
|
static cDialog* topWindow; // Tracks the frontmost dialog.
|
||||||
public:
|
public:
|
||||||
|
static void (*redraw_everything)();
|
||||||
/// Performs essential startup initialization. Generally should not be called directly.
|
/// Performs essential startup initialization. Generally should not be called directly.
|
||||||
static void init();
|
static void init();
|
||||||
/// The light background pattern used by the scenario editor dialogs.
|
/// The light background pattern used by the scenario editor dialogs.
|
||||||
|
@@ -115,6 +115,8 @@ int main(int argc, char* argv[]) {
|
|||||||
debug_oldstructs();
|
debug_oldstructs();
|
||||||
#endif
|
#endif
|
||||||
try{
|
try{
|
||||||
|
cDialog::redraw_everything = &redraw_everything;
|
||||||
|
|
||||||
init_boe(argc, argv);
|
init_boe(argc, argv);
|
||||||
|
|
||||||
if(!get_bool_pref("GameRunBefore"))
|
if(!get_bool_pref("GameRunBefore"))
|
||||||
|
Reference in New Issue
Block a user