Permalink
Browse files

code clean up and fixed option box view change and a seg fault

- option box in Item menu properly resets to top of list when you change
  item category

- there was a bug when you had no available items at all where
  the bottom window would try to render with an invalid object. this
  should be fixed now
  • Loading branch information...
1 parent 4016708 commit a388e5772e411107af684cfa1eac63875310a332 @IkarusDowned IkarusDowned committed Dec 27, 2012
Showing with 244 additions and 193 deletions.
  1. +5 −1 src/common/gui/option.cpp
  2. +11 −0 src/common/gui/option.h
  3. +13 −4 src/modes/menu/menu.cpp
  4. +4 −2 src/modes/menu/menu.h
  5. +207 −186 src/modes/menu/menu_views.cpp
  6. +4 −0 src/modes/menu/menu_views.h
@@ -346,7 +346,11 @@ void OptionBox::ClearOptions()
_options.clear();
}
-
+void OptionBox::ResetViewableOption()
+{
+ _draw_top_row = 0;
+ _draw_left_column = 0;
+}
void OptionBox::AddOption()
{
View
@@ -370,6 +370,17 @@ class OptionBox : public private_gui::GUIControl
**/
bool IsInitialized(std::string &error_messages);
+ /**
+ *** \brief resets the viewing selection to the top-most option.
+ *** this essentially forces the draw top and draw left to be set to zero
+ *** \note This call must be called INDEPENDENTLY of ClearOptions() or SetOptions(), etc.
+ *** because every frame, it is possible that we "reset" the actual options via a ClearOptions() / SetOptions() call,
+ *** but we don't want to reset the VIEWABLE option number. for example, scrolling options boxes must keep
+ *** the top-most / left-most row / column across frames since the # of options (probably) hasn't change
+ *** but you would probably want to reset to the top most option if the options in their entirety changed
+ **/
+ void ResetViewableOption();
+
/** \name Input Processing Methods
*** \brief Processes the input commands for moving the cursor, selecting options, etcetra
**/
View
@@ -181,7 +181,8 @@ void AbstractMenuState::Draw()
// Draw currently active options box
_options.Draw();
}
-void AbstractMenuState::_DrawEquipmentInfo(hoa_global::GlobalCharacter* character)
+
+void AbstractMenuState::_DrawEquipmentInfo(hoa_global::GlobalCharacter *character)
{
VideoManager->Text()->Draw(UTranslate("STR: ") + MakeUnicodeString(NumberToString(character->GetStrength())));
@@ -425,7 +426,7 @@ void InventoryState::_OnDraw()
}
}
-void InventoryState::_DrawItemDescription(hoa_global::GlobalObject &obj,hoa_video::StillImage& item_image,hoa_gui::TextBox& description)
+void InventoryState::_DrawItemDescription(hoa_global::GlobalObject &obj,hoa_video::StillImage &item_image,hoa_gui::TextBox &description)
{
int32 key_pos_x = 100 + obj.GetIconImage().GetWidth() - item_image.GetWidth() - 3;
int32 key_pos_y = 600 + obj.GetIconImage().GetHeight() - item_image.GetHeight() - 3;
@@ -439,8 +440,13 @@ void InventoryState::_DrawBottomMenu()
_menu_mode->_bottom_window.Draw();
+ //if we are out of items, the bottom view should show nothing
+ if(_menu_mode->_inventory_window._item_objects.size() == 0)
+ return;
+
VideoManager->SetDrawFlags(VIDEO_X_LEFT, VIDEO_Y_BOTTOM, 0);
VideoManager->Move(150, 580);
+
GlobalObject *obj = _menu_mode->_inventory_window._item_objects[ _menu_mode->_inventory_window._inventory_items.GetSelection() ];
const GLOBAL_OBJECT obj_type = obj->GetObjectType();
if(_menu_mode->_inventory_window._active_box == ITEM_ACTIVE_LIST) {
@@ -563,7 +569,7 @@ void InventoryState::_DrawBottomMenu()
else
{
//otherwise print a message
- static ustring cannot_equip = MakeUnicodeString("This character cannot equip this item"); //load this from script?
+ const static ustring cannot_equip = MakeUnicodeString("This character cannot equip this item"); //If more flexibility is needed down the road, load this from script
VideoManager->Move(185, 600);
VideoManager->Text()->Draw(cannot_equip);
}
@@ -734,7 +740,10 @@ void EquipState::_OnDraw()
_DrawBottomMenu();
_menu_mode->_equip_window.Draw();
}
-void EquipState::DrawEquipmentInfo(ustring& equipment_name,bool is_weapon,uint32 physical_attribute, uint32 magical_attribute, uint32 current_phys_attribute,uint32 current_mag_attribute)
+void EquipState::DrawEquipmentInfo(const ustring &equipment_name,
+ bool is_weapon, uint32 physical_attribute,
+ uint32 magical_attribute, uint32 current_phys_attribute,
+ uint32 current_mag_attribute)
{
// Display the info
VideoManager->Move(755, 577);
View
@@ -182,7 +182,7 @@ class InventoryState : virtual public AbstractMenuState {
void Reset();
AbstractMenuState* GetTransitionState(uint32 selection);
protected:
- void _DrawItemDescription(hoa_global::GlobalObject &obj,hoa_video::StillImage& item_image,hoa_gui::TextBox& description);
+ void _DrawItemDescription(hoa_global::GlobalObject &obj,hoa_video::StillImage &item_image,hoa_gui::TextBox &description);
void _DrawBottomMenu();
void _OnDraw();
void _ActiveWindowUpdate();
@@ -259,7 +259,9 @@ class EquipState : virtual public AbstractMenuState {
void Reset();
AbstractMenuState* GetTransitionState(uint32 selection);
//handles drawing the bottom window info for equipment
- static void DrawEquipmentInfo(hoa_utils::ustring& equipment_name,bool is_weapon = false, uint32 physical_attribute=0, uint32 magical_attribute=0, uint32 current_phys_attribute=0,uint32 current_mag_attribute=0);
+ static void DrawEquipmentInfo(const hoa_utils::ustring &equipment_name, bool is_weapon = false,
+ uint32 physical_attribute=0, uint32 magical_attribute=0,
+ uint32 current_phys_attribute=0, uint32 current_mag_attribute=0);
protected:
void _DrawBottomMenu();
void _OnDraw();
Oops, something went wrong.

0 comments on commit a388e57

Please sign in to comment.