litchie / exult-ios

Exult ( http://exult.sourceforge.net/ )
GNU General Public License v2.0
42 stars 8 forks source link

Shortcut bar - update on new items, combat, resolution changes #30

Closed DominusExult closed 8 years ago

DominusExult commented 9 years ago

The shortcut bar needs some kind of auto updating when things change (similar to the face_stats).

I've got two savegames of Serpent Isle for testing the item changes: https://www.dropbox.com/s/br1vcfxikgfklog/exult01si.sav?dl=0 which has spellbook, keyring, jawbone in front of the avatar, for easy adding to the inventory https://www.dropbox.com/s/id7gyvxkt3dws6n/exult02si.sav?dl=0 has them already added

DominusExult commented 9 years ago

I tried to copy from face_stats and made this NON-WORKING patch

diff --git a/gumps/iphone_gumps.cc b/gumps/iphone_gumps.cc
index 29a20a3..4b592b7 100644
--- a/gumps/iphone_gumps.cc
+++ b/gumps/iphone_gumps.cc
@@ -87,6 +87,31 @@ bool ShortcutBar_gump::is_party_item(
    return false;
 }

+// add dirty region, if dirty
+void ShortcutBar_gump::update_gump() {
+   if (has_changed()) {
+       deleteButtons();
+       createButtons();
+   }
+}
+
+// Has this changed?
+bool ShortcutBar_gump::has_changed() {
+   if (resx != gwin->get_win()->get_full_width() ||
+          resy != gwin->get_win()->get_full_height() ||
+           gamex != gwin->get_game_width() ||
+           gamey != gwin->get_game_height())
+       return true;
+   //spellbook
+   if (is_party_item(761)) return true;
+   
+   // SI keyring
+   if (is_party_item(485) && GAME_SI) return true;
+
+   // SI Jawbone
+   if (is_party_item(555) && GAME_SI) return true;
+}
+
 /*
  * To align button shapes vertically, we need to micro-manage the shapeOffsetY
  * values to shift shapes up or down.
diff --git a/gumps/iphone_gumps.h b/gumps/iphone_gumps.h
index 846462d..b5ffe9a 100644
--- a/gumps/iphone_gumps.h
+++ b/gumps/iphone_gumps.h
@@ -85,12 +85,15 @@ public:
    virtual bool no_handcursor() const {
        return true;
    }
+   int resx = gwin->get_win()->get_full_width();
    int gamex = gwin->get_game_width();
    int starty = gwin->get_win()->get_start_y();
    int resy = gwin->get_win()->get_full_height();
    int gamey = gwin->get_game_height();
    void onUserEvent(SDL_Event *event);
-   
+   // add dirty region, if dirty
+   virtual void update_gump();
+
 private:
    ShortcutBarButtonItem buttonItems[MAX_SHORTCUT_BAR_ITEMS];
    int numButtons;
@@ -104,6 +107,7 @@ private:
    void onItemClicked(int index, bool doubleClicked);
    void mouse_down(SDL_Event *event, int mx, int my);
    void mouse_up(SDL_Event *event, int mx, int my);
+   bool has_changed();

    int locx;
    int locy;

Hoped that might work :(

DominusExult commented 8 years ago

All these are now working (needed ownership changed from exult.cc to gamewin.cc) in 6df4497. Only problem is that the Aspect correction doesn't update the shortcut bar, so it is hidden until a restart.