game: fix buggy panel geometry saving/restoring

This commit is contained in:
Crypto City 2020-09-09 13:03:21 +00:00
parent 5362219097
commit abb91e3d8d
4 changed files with 18 additions and 6 deletions

View File

@ -2955,7 +2955,7 @@ void CryptoCityUrho3D::HandleMainPanelGeometry(StringHash eventType, VariantMap&
eventData[MainPanelGeometry::P_Y] = y; eventData[MainPanelGeometry::P_Y] = y;
eventData[MainPanelGeometry::P_WIDTH] = width; eventData[MainPanelGeometry::P_WIDTH] = width;
eventData[MainPanelGeometry::P_HEIGHT] = height; eventData[MainPanelGeometry::P_HEIGHT] = height;
eventData[MainPanelGeometry::P_SHADED] = shaded; eventData[MainPanelGeometry::P_SHADED] = (bool)shaded;
} }
} }

View File

@ -61,6 +61,7 @@ public:
bool Shade(bool shade); bool Shade(bool shade);
bool IsShaded() const; bool IsShaded() const;
int GetUnshadedHeight() const { return unshaded_height; }
static bool HasModalDialog(); static bool HasModalDialog();
static bool CloseModal(); static bool CloseModal();

View File

@ -89,18 +89,25 @@ using namespace tb;
class MainPanel: public UITBWindow class MainPanel: public UITBWindow
{ {
public: public:
MainPanel(Urho3D::Context *ctx, const char *resource): UITBWindow(ctx, resource) {} MainPanel(Urho3D::Context *ctx, const char *resource): UITBWindow(ctx, resource), configured(false) {}
virtual void SetRect(const TBRect &rect) virtual void SetRect(const TBRect &rect)
{ {
UITBWindow::SetRect(rect); UITBWindow::SetRect(rect);
if (!configured)
return;
const bool shaded = IsShaded();
VariantMap eventData; VariantMap eventData;
eventData[MainPanelGeometry::P_X] = rect.x; eventData[MainPanelGeometry::P_X] = rect.x;
eventData[MainPanelGeometry::P_Y] = rect.y; eventData[MainPanelGeometry::P_Y] = rect.y;
eventData[MainPanelGeometry::P_WIDTH] = rect.w; eventData[MainPanelGeometry::P_WIDTH] = rect.w;
eventData[MainPanelGeometry::P_HEIGHT] = rect.h; eventData[MainPanelGeometry::P_HEIGHT] = shaded ? GetUnshadedHeight() : rect.h;
eventData[MainPanelGeometry::P_SHADED] = IsShaded(); eventData[MainPanelGeometry::P_SHADED] = shaded;
SendEvent(E_CRYPTOCITY_MAIN_PANEL_GEOMETRY, eventData); SendEvent(E_CRYPTOCITY_MAIN_PANEL_GEOMETRY, eventData);
} }
void OnConfigured() { configured = true; }
private:
bool configured;
}; };
static uint64_t get_shares(const GameState *game, const Map *map, const std::shared_ptr<Flag> &iflag, uint32_t special_event) static uint64_t get_shares(const GameState *game, const Map *map, const std::shared_ptr<Flag> &iflag, uint32_t special_event)
@ -301,9 +308,12 @@ void UIUrho3D::Configure()
y = 0; y = 0;
if (width > 0 && height > 0) if (width > 0 && height > 0)
{ {
command_window->Shade(shaded); command_window->Shade(false);
command_window->SetRect({x, y, width, height}); command_window->SetRect({x, y, width, height});
if (shaded)
command_window->Shade(true);
} }
command_window->OnConfigured();
} }
void UIUrho3D::CreateSpectatorModeWidget() void UIUrho3D::CreateSpectatorModeWidget()

View File

@ -21,6 +21,7 @@
#include "map.h" #include "map.h"
class GameWallet; class GameWallet;
class MainPanel;
class UIBuildingSettingsDialog; class UIBuildingSettingsDialog;
class UILastUpdateEventsDialog; class UILastUpdateEventsDialog;
@ -444,7 +445,7 @@ private:
UIMintDialog *mintDialog; UIMintDialog *mintDialog;
UISmeltDialog *smeltDialog; UISmeltDialog *smeltDialog;
UITBWindow *command_window; MainPanel *command_window;
Urho3D::IntVector2 prev_size; Urho3D::IntVector2 prev_size;
std::unordered_map<std::string, cryptonote::cc_command_t> queued_commands, queued_commands_except_unmatched_trades; std::unordered_map<std::string, cryptonote::cc_command_t> queued_commands, queued_commands_except_unmatched_trades;