MenuActiveEffects::MenuActiveEffects(StatBlock *_stats) : timer(NULL) , stats(_stats) , orientation(false) { // horizontal // Load config settings FileParser infile; // @CLASS MenuActiveEffects|Description of menus/activeeffects.txt if(infile.open("menus/activeeffects.txt")) { while(infile.next()) { if (parseMenuKey(infile.key, infile.val)) continue; // @ATTR orientation|bool|True is vertical orientation; False is horizontal orientation. if(infile.key == "orientation") { orientation = toBool(infile.val); } else { infile.error("MenuActiveEffects: '%s' is not a valid key.", infile.key.c_str()); } } infile.close(); } loadGraphics(); align(); }
MenuHUDLog::MenuHUDLog() : overlay_bg(NULL) , click_to_dismiss(false) , hide_overlay(false) { // Load config settings FileParser infile; if(infile.open("menus/hudlog.txt")) { while(infile.next()) { if (parseMenuKey(infile.key, infile.val)) continue; else infile.error("MenuHUDLog: '%s' is not a valid key.", infile.key.c_str()); } infile.close(); } align(); font->setFont("font_regular"); paragraph_spacing = font->getLineHeight()/2; color_normal = font->getColor("menu_normal"); }
MenuExit::MenuExit() : Menu() { // Load config settings FileParser infile; if(infile.open("menus/exit.txt")) { while(infile.next()) { if (parseMenuKey(infile.key, infile.val)) continue; } infile.close(); } exitClicked = false; buttonExit = new WidgetButton("images/menus/buttons/button_default.png"); buttonExit->label = msg->get("Exit"); buttonClose = new WidgetButton("images/menus/buttons/button_x.png"); setBackground("images/menus/confirm_bg.png"); tablist.add(buttonExit); tablist.add(buttonClose); align(); alignElements(); }
MenuConfirm::MenuConfirm(const std::string& _buttonMsg, const std::string& _boxMsg) : Menu() , buttonConfirm(NULL) , buttonClose(NULL) , hasConfirmButton(false) , confirmClicked(false) , cancelClicked(false) , isWithinButtons(false) { // Load config settings FileParser infile; if(infile.open("menus/confirm.txt")) { while(infile.next()) { if (parseMenuKey(infile.key, infile.val)) continue; } infile.close(); } if (_buttonMsg != "") hasConfirmButton = true; // Text to display in confirmation box boxMsg = _boxMsg; if (hasConfirmButton) { buttonConfirm = new WidgetButton(); buttonConfirm->label = _buttonMsg; tablist.add(buttonConfirm); } buttonClose = new WidgetButton("images/menus/buttons/button_x.png"); tablist.add(buttonClose); setBackground("images/menus/confirm_bg.png"); align(); }
MenuExit::MenuExit() : Menu() { // Load config settings FileParser infile; if(infile.open("menus/exit.txt")) { while(infile.next()) { if (parseMenuKey(infile.key, infile.val)) continue; else infile.error("MenuExit: '%s' is not a valid key.", infile.key.c_str()); } infile.close(); } exitClicked = false; buttonExit = new WidgetButton(); if (SAVE_ONEXIT) buttonExit->label = msg->get("Save & Exit"); else buttonExit->label = msg->get("Exit"); buttonClose = new WidgetButton("images/menus/buttons/button_x.png"); setBackground("images/menus/confirm_bg.png"); tablist.add(buttonExit); tablist.add(buttonClose); align(); }
MenuDevConsole::MenuDevConsole() : Menu() { button_close = new WidgetButton("images/menus/buttons/button_x.png"); tablist.add(button_close); input_box = new WidgetInput("images/menus/input_console.png"); tablist.add(input_box); button_confirm = new WidgetButton(); button_confirm->label = msg->get("Execute"); tablist.add(button_confirm); // Load config settings FileParser infile; // @CLASS MenuDevConsole|Description of menus/devconsole.txt if(infile.open("menus/devconsole.txt")) { while(infile.next()) { if (parseMenuKey(infile.key, infile.val)) continue; // @ATTR close|x (integer), y (integer)|Position of the close button. if(infile.key == "close") { Point pos = toPoint(infile.val); button_close->setBasePos(pos.x, pos.y); } // @ATTR label_title|label|Position of the "Developer Console" label. else if(infile.key == "label_title") title = eatLabelInfo(infile.val); // @ATTR confirm|x (integer), y (integer)|Position of the "Execute" button. else if(infile.key == "confirm") { Point pos = toPoint(infile.val); button_confirm->setBasePos(pos.x, pos.y); } // @ATTR input|x (integer), y (integer)|Position of the command entry widget. else if(infile.key == "input") { Point pos = toPoint(infile.val); input_box->setBasePos(pos.x, pos.y); } // @ATTR history|x (integer), y (integer), w (integer), h (integer)|Position and dimensions of the command history. else if(infile.key == "history") history_area = toRect(infile.val); else infile.error("MenuDevConsole: '%s' is not a valid key.", infile.key.c_str()); } infile.close(); } log_history = new WidgetLog(history_area.w, history_area.h); log_history->setBasePos(history_area.x, history_area.y); tablist.add(log_history->getWidget()); setBackground("images/menus/dev_console.png"); color_echo = font->getColor("widget_disabled"); color_error = font->getColor("menu_penalty"); align(); input_box->inFocus = true; }
MenuLog::MenuLog() { visible = false; closeButton = new WidgetButton("images/menus/buttons/button_x.png"); // Load config settings FileParser infile; // @CLASS MenuLog|Description of menus/log.txt if(infile.open("menus/log.txt")) { while(infile.next()) { if (parseMenuKey(infile.key, infile.val)) continue; // @ATTR label_title|label|Position of the "Log" text. if(infile.key == "label_title") { title = eatLabelInfo(infile.val); } // @ATTR close|point|Position of the close button. else if(infile.key == "close") { Point pos = toPoint(infile.val); closeButton->setBasePos(pos.x, pos.y); } // @ATTR tab_area|rectangle|The position of the row of tabs, followed by the dimensions of the log text area. else if(infile.key == "tab_area") { tab_area = toRect(infile.val); } else { infile.error("MenuLog: '%s' is not a valid key.", infile.key.c_str()); } } infile.close(); } // Initialize the tab control. tabControl = new WidgetTabControl(); tablist.add(tabControl); // Store the amount of displayed log messages on each log, and the maximum. tablist_log.resize(LOG_TYPE_COUNT); for (unsigned i=0; i<LOG_TYPE_COUNT; i++) { log[i] = new WidgetLog(tab_area.w,tab_area.h); log[i]->setBasePos(tab_area.x, tab_area.y + tabControl->getTabHeight()); tablist_log[i].add(log[i]->getWidget()); tablist_log[i].setPrevTabList(&tablist); tablist_log[i].lock(); } // Define the header. tabControl->setTabTitle(LOG_TYPE_MESSAGES, msg->get("Notes")); tabControl->setTabTitle(LOG_TYPE_QUESTS, msg->get("Quests")); setBackground("images/menus/log.png"); align(); }
MenuPowers::MenuPowers(StatBlock *_stats, MenuActionBar *_action_bar) : stats(_stats) , action_bar(_action_bar) , skip_section(false) , powers_unlock(NULL) , overlay_disabled(NULL) , points_left(0) , default_background("") , tab_control(NULL) , tree_loaded(false) , prev_powers_list_size(0) , newPowerNotification(false) { closeButton = new WidgetButton("images/menus/buttons/button_x.png"); // Read powers data from config file FileParser infile; // @CLASS MenuPowers: Menu layout|Description of menus/powers.txt if (infile.open("menus/powers.txt")) { while (infile.next()) { if (parseMenuKey(infile.key, infile.val)) continue; // @ATTR label_title|label|Position of the "Powers" text. if (infile.key == "label_title") title = eatLabelInfo(infile.val); // @ATTR unspent_points|label|Position of the text that displays the amount of unused power points. else if (infile.key == "unspent_points") unspent_points = eatLabelInfo(infile.val); // @ATTR close|point|Position of the close button. else if (infile.key == "close") close_pos = toPoint(infile.val); // @ATTR tab_area|rectangle|Position and dimensions of the tree pages. else if (infile.key == "tab_area") tab_area = toRect(infile.val); else infile.error("MenuPowers: '%s' is not a valid key.", infile.key.c_str()); } infile.close(); } loadGraphics(); menu_powers = this; color_bonus = font->getColor("menu_bonus"); color_penalty = font->getColor("menu_penalty"); color_flavor = font->getColor("item_flavor"); align(); }
MenuDevHUD::MenuDevHUD() : Menu() { // Load config settings FileParser infile; // @CLASS MenuDevHUD|Description of menus/devhud.txt if(infile.open("menus/devhud.txt")) { while(infile.next()) { if (parseMenuKey(infile.key, infile.val)) continue; else infile.error("MenuDevHUD: '%s' is not a valid key.", infile.key.c_str()); } infile.close(); } original_area = window_area; alignElements(); }
MenuEnemy::MenuEnemy() : bar_hp(NULL) , custom_text_pos(false) , enemy(NULL) , timeout(0) { // Load config settings FileParser infile; // @CLASS MenuEnemy|Description of menus/enemy.txt if(infile.open("menus/enemy.txt")) { while(infile.next()) { if (parseMenuKey(infile.key, infile.val)) continue; infile.val = infile.val + ','; // @ATTR bar_pos|rectangle|Position and dimensions of the health bar. if(infile.key == "bar_pos") { bar_pos = toRect(infile.val); } // @ATTR text_pos|label|Position of the text displaying the enemy's name and level. else if(infile.key == "text_pos") { custom_text_pos = true; text_pos = eatLabelInfo(infile.val); } else { infile.error("MenuEnemy: '%s' is not a valid key.", infile.key.c_str()); } } infile.close(); } loadGraphics(); color_normal = font->getColor("menu_normal"); align(); }
MenuStash::MenuStash() : Menu() , closeButton(new WidgetButton("images/menus/buttons/button_x.png")) , tab_control(new WidgetTabControl()) , activetab(STASH_PRIVATE) , drag_prev_tab(-1) , stock() , updated(false) { tab_control->setTabTitle(STASH_PRIVATE, msg->get("Private")); if (!pc->stats.permadeath) tab_control->setTabTitle(STASH_SHARED, msg->get("Shared")); setBackground("images/menus/stash.png"); int slots_cols = 8; // default if menus/stash.txt::stash_cols not set int slots_rows = 8; // default if menus/stash.txt::slots_rows not set // Load config settings FileParser infile; // @CLASS MenuStash|Description of menus/stash.txt if (infile.open("menus/stash.txt", FileParser::MOD_FILE, FileParser::ERROR_NORMAL)) { while(infile.next()) { if (parseMenuKey(infile.key, infile.val)) continue; // @ATTR close|point|Position of the close button. if (infile.key == "close") { Point pos = Parse::toPoint(infile.val); closeButton->setBasePos(pos.x, pos.y, Utils::ALIGN_TOPLEFT); } // @ATTR slots_area|point|Position of the top-left slot. else if (infile.key == "slots_area") { slots_area.x = Parse::popFirstInt(infile.val); slots_area.y = Parse::popFirstInt(infile.val); } // @ATTR stash_cols|int|The number of columns for the grid of slots. else if (infile.key == "stash_cols") { slots_cols = std::max(1, Parse::toInt(infile.val)); } // @ATTR stash_rows|int|The number of rows for the grid of slots. else if (infile.key == "stash_rows") { slots_rows = std::max(1, Parse::toInt(infile.val)); } // @ATTR label_title|label|Position of the "Stash" label. else if (infile.key == "label_title") { label_title.setFromLabelInfo(Parse::popLabelInfo(infile.val)); } // @ATTR currency|label|Position of the label displaying the amount of currency stored in the stash. else if (infile.key == "currency") { label_currency.setFromLabelInfo(Parse::popLabelInfo(infile.val)); } else { infile.error("MenuStash: '%s' is not a valid key.", infile.key.c_str()); } } infile.close(); } label_title.setText(msg->get("Stash")); label_title.setColor(font->getColor(FontEngine::COLOR_MENU_NORMAL)); label_currency.setColor(font->getColor(FontEngine::COLOR_MENU_NORMAL)); int stash_slots = slots_cols * slots_rows; slots_area.w = slots_cols * eset->resolutions.icon_size; slots_area.h = slots_rows * eset->resolutions.icon_size; stock[STASH_PRIVATE].initGrid(stash_slots, slots_area, slots_cols); stock[STASH_SHARED].initGrid(stash_slots, slots_area, slots_cols); tablist.add(tab_control); tablist_private.setPrevTabList(&tablist); tablist_shared.setPrevTabList(&tablist); tablist_private.lock(); tablist_shared.lock(); for (int i = 0; i < stash_slots; i++) { tablist_private.add(stock[STASH_PRIVATE].slots[i]); tablist_shared.add(stock[STASH_SHARED].slots[i]); } align(); }
MenuVendor::MenuVendor(StatBlock *_stats) : Menu() , stats(_stats) , closeButton(new WidgetButton("images/menus/buttons/button_x.png")) , tabControl(new WidgetTabControl()) , slots_cols(1) , slots_rows(1) , activetab(VENDOR_BUY) , color_normal(font->getColor("menu_normal")) , npc(NULL) , buyback_stock() { setBackground("images/menus/vendor.png"); tabControl->setTabTitle(VENDOR_BUY, msg->get("Inventory")); tabControl->setTabTitle(VENDOR_SELL, msg->get("Buyback")); // Load config settings FileParser infile; // @CLASS MenuVendor|Description of menus/vendor.txt if(infile.open("menus/vendor.txt")) { while(infile.next()) { if (parseMenuKey(infile.key, infile.val)) continue; // @ATTR close|x (integer), y (integer)|Position of the close button. if(infile.key == "close") { Point pos = toPoint(infile.val); closeButton->setBasePos(pos.x, pos.y); } // @ATTR slots_area|x (integer), y (integer)|Position of the top-left slot. else if(infile.key == "slots_area") { slots_area.x = popFirstInt(infile.val); slots_area.y = popFirstInt(infile.val); } // @ATTR vendor_cols|integer|The number of columns in the grid of slots. else if (infile.key == "vendor_cols") { slots_cols = std::max(1, toInt(infile.val)); } // @ATTR vendor_rows|integer|The number of rows in the grid of slots. else if (infile.key == "vendor_rows") { slots_rows = std::max(1, toInt(infile.val)); } // @ATTR label_title|label|The position of the text that displays the NPC's name. else if (infile.key == "label_title") { title = eatLabelInfo(infile.val); } else { infile.error("MenuVendor: '%s' is not a valid key.", infile.key.c_str()); } } infile.close(); } VENDOR_SLOTS = slots_cols * slots_rows; slots_area.w = slots_cols*ICON_SIZE; slots_area.h = slots_rows*ICON_SIZE; stock[VENDOR_BUY].init(VENDOR_SLOTS, slots_area, ICON_SIZE, slots_cols); stock[VENDOR_SELL].init(VENDOR_SLOTS, slots_area, ICON_SIZE, slots_cols); buyback_stock.init(NPC_VENDOR_MAX_STOCK); for (unsigned i = 0; i < VENDOR_SLOTS; i++) { tablist.add(stock[VENDOR_BUY].slots[i]); } for (unsigned i = 0; i < VENDOR_SLOTS; i++) { tablist.add(stock[VENDOR_SELL].slots[i]); } align(); }
MenuTalker::MenuTalker(MenuManager *_menu) : Menu() , menu(_menu) , portrait(NULL) , dialog_node(0) , event_cursor(0) , font_who("font_regular") , font_dialog("font_regular") , color_normal(font->getColor("menu_normal")) , npc(NULL) , advanceButton(new WidgetButton("images/menus/buttons/right.png")) , closeButton(new WidgetButton("images/menus/buttons/button_x.png")) { setBackground("images/menus/dialog_box.png"); // Load config settings FileParser infile; // @CLASS MenuTalker|Description of menus/talker.txt if(infile.open("menus/talker.txt")) { while(infile.next()) { if (parseMenuKey(infile.key, infile.val)) continue; // @ATTR close|x (integer), y (integer)|Position of the close button. if(infile.key == "close") { Point pos = toPoint(infile.val); closeButton->setBasePos(pos.x, pos.y); } // @ATTR advance|x (integer), y (integer)|Position of the button to advance dialog. else if(infile.key == "advance") { Point pos = toPoint(infile.val); advanceButton->setBasePos(pos.x, pos.y); } // @ATTR dialogbox|x (integer), y (integer), w (integer), h (integer)|Position and dimensions of the text box graphics. else if (infile.key == "dialogbox") dialog_pos = toRect(infile.val); // @ATTR dialogtext|x (integer), y (integer), w (integer), h (integer)|Rectangle where the dialog text is placed. else if (infile.key == "dialogtext") text_pos = toRect(infile.val); // @ATTR text_offset|x (integer), y (integer)|Margins for the left/right and top/bottom of the dialog text. else if (infile.key == "text_offset") text_offset = toPoint(infile.val); // @ATTR portrait_he|x (integer), y (integer), w (integer), h (integer)|Position and dimensions of the NPC portrait graphics. else if (infile.key == "portrait_he") portrait_he = toRect(infile.val); // @ATTR portrait_you|x (integer), y (integer), w (integer), h (integer)|Position and dimensions of the player's portrait graphics. else if (infile.key == "portrait_you") portrait_you = toRect(infile.val); // @ATTR font_who|string|Font style to use for the name of the currently talking person. else if (infile.key == "font_who") font_who = infile.val; // @ATTR font_dialog|string|Font style to use for the dialog text. else if (infile.key == "font_dialog") font_dialog = infile.val; else infile.error("MenuTalker: '%s' is not a valid key.", infile.key.c_str()); } infile.close(); } label_name = new WidgetLabel(); label_name->setBasePos(text_pos.x + text_offset.x, text_pos.y + text_offset.y); textbox = new WidgetScrollBox(text_pos.w, text_pos.h-(text_offset.y*2)); textbox->setBasePos(text_pos.x, text_pos.y + text_offset.y); tablist.add(advanceButton); tablist.add(closeButton); tablist.add(textbox); align(); }
MenuActionBar::MenuActionBar() : sprite_emptyslot(NULL) , sprite_disabled(NULL) , sprite_attention(NULL) , slots_count(0) , drag_prev_slot(-1) , updated(false) , twostep_slot(-1) { src.w = ICON_SIZE; src.h = ICON_SIZE; menu_labels.resize(4); tablist = TabList(HORIZONTAL, ACTIONBAR_BACK, ACTIONBAR_FORWARD, ACTIONBAR); for (unsigned int i=0; i<4; i++) { menus[i] = new WidgetSlot(-1, ACTIONBAR); } // Read data from config file FileParser infile; // @CLASS MenuActionBar|Description of menus/actionbar.txt if (infile.open("menus/actionbar.txt")) { while (infile.next()) { if (parseMenuKey(infile.key, infile.val)) continue; // @ATTR slot|repeatable(int, int, int) : Index, X, Y|Index (max 10) and position for power slot. if (infile.key == "slot") { unsigned index = popFirstInt(infile.val); if (index == 0 || index > 10) { infile.error("MenuActionBar: Slot index must be in range 1-10."); } else { int x = popFirstInt(infile.val); int y = popFirstInt(infile.val); addSlot(index-1, x, y); } } // @ATTR slot_M1|point|Position for the primary action slot. else if (infile.key == "slot_M1") { int x = popFirstInt(infile.val); int y = popFirstInt(infile.val); addSlot(10, x, y); } // @ATTR slot_M2|point|Position for the secondary action slot. else if (infile.key == "slot_M2") { int x = popFirstInt(infile.val); int y = popFirstInt(infile.val); addSlot(11, x, y); } // @ATTR char_menu|point|Position for the Character menu button. else if (infile.key == "char_menu") { int x = popFirstInt(infile.val); int y = popFirstInt(infile.val); menus[MENU_CHARACTER]->setBasePos(x, y); menus[MENU_CHARACTER]->pos.w = menus[MENU_CHARACTER]->pos.h = ICON_SIZE; } // @ATTR inv_menu|point|Position for the Inventory menu button. else if (infile.key == "inv_menu") { int x = popFirstInt(infile.val); int y = popFirstInt(infile.val); menus[MENU_INVENTORY]->setBasePos(x, y); menus[MENU_INVENTORY]->pos.w = menus[MENU_INVENTORY]->pos.h = ICON_SIZE; } // @ATTR powers_menu|point|Position for the Powers menu button. else if (infile.key == "powers_menu") { int x = popFirstInt(infile.val); int y = popFirstInt(infile.val); menus[MENU_POWERS]->setBasePos(x, y); menus[MENU_POWERS]->pos.w = menus[MENU_POWERS]->pos.h = ICON_SIZE; } // @ATTR log_menu|point|Position for the Log menu button. else if (infile.key == "log_menu") { int x = popFirstInt(infile.val); int y = popFirstInt(infile.val); menus[MENU_LOG]->setBasePos(x, y); menus[MENU_LOG]->pos.w = menus[MENU_LOG]->pos.h = ICON_SIZE; } else infile.error("MenuActionBar: '%s' is not a valid key.", infile.key.c_str()); } infile.close(); } for (unsigned int i=0; i<4; i++) { tablist.add(menus[i]); } slots_count = static_cast<unsigned>(slots.size()); hotkeys.resize(slots_count); hotkeys_temp.resize(slots_count); hotkeys_mod.resize(slots_count); locked.resize(slots_count); slot_item_count.resize(slots_count); slot_enabled.resize(slots_count); slot_activated.resize(slots_count); slot_cooldown_size.resize(slots_count); clear(); loadGraphics(); align(); menu_act = this; }
MenuInventory::MenuInventory(StatBlock *_stats) { stats = _stats; MAX_EQUIPPED = 4; MAX_CARRIED = 64; visible = false; setBackground("images/menus/inventory.png"); currency = 0; carried_cols = 4; // default to 4 if menus/inventory.txt::carried_cols not set carried_rows = 4; // default to 4 if menus/inventory.txt::carried_rows not set drag_prev_src = -1; changed_equipment = true; log_msg = ""; show_book = ""; closeButton = new WidgetButton("images/menus/buttons/button_x.png"); // Load config settings FileParser infile; // @CLASS MenuInventory|Description of menus/inventory.txt if (infile.open("menus/inventory.txt")) { while(infile.next()) { if (parseMenuKey(infile.key, infile.val)) continue; // @ATTR close|x (integer), y (integer)|Position of the close button. if(infile.key == "close") { Point pos = toPoint(infile.val); closeButton->setBasePos(pos.x, pos.y); } // @ATTR equipment_slot|x (integer), y (integer), size (integer), slot_type (string)|Position and item type of an equipment slot. else if(infile.key == "equipment_slot") { Rect area; Point pos; pos.x = area.x = popFirstInt(infile.val); pos.y = area.y = popFirstInt(infile.val); area.w = area.h = popFirstInt(infile.val); equipped_area.push_back(area); equipped_pos.push_back(pos); slot_type.push_back(popFirstString(infile.val)); } // @ATTR slot_name|string|The displayed name of the last defined equipment slot. else if(infile.key == "slot_name") slot_desc.push_back(infile.val); // @ATTR carried_area|x (integer), y (integer)|Position of the first normal inventory slot. else if(infile.key == "carried_area") { Point pos; carried_pos.x = carried_area.x = popFirstInt(infile.val); carried_pos.y = carried_area.y = popFirstInt(infile.val); } // @ATTR carried_cols|integer|The number of columns for the normal inventory. else if (infile.key == "carried_cols") carried_cols = std::max(1, toInt(infile.val)); // @ATTR carried_rows|integer|The number of rows for the normal inventory. else if (infile.key == "carried_rows") carried_rows = std::max(1, toInt(infile.val)); // @ATTR label_title|label|Position of the "Inventory" label. else if (infile.key == "label_title") title = eatLabelInfo(infile.val); // @ATTR currency|label|Position of the label that displays the total currency being carried. else if (infile.key == "currency") currency_lbl = eatLabelInfo(infile.val); // @ATTR help|x (integer), y (integer), w (integer), h (integer)|A mouse-over area that displays some help text for inventory shortcuts. else if (infile.key == "help") help_pos = toRect(infile.val); else infile.error("MenuInventory: '%s' is not a valid key.", infile.key.c_str()); } infile.close(); } MAX_EQUIPPED = equipped_area.size(); MAX_CARRIED = carried_cols * carried_rows; carried_area.w = carried_cols*ICON_SIZE; carried_area.h = carried_rows*ICON_SIZE; color_normal = font->getColor("menu_normal"); color_high = font->getColor("menu_bonus"); inventory[EQUIPMENT].init(MAX_EQUIPPED, equipped_area, slot_type); inventory[CARRIED].init(MAX_CARRIED, carried_area, ICON_SIZE, carried_cols); for (int i = 0; i < MAX_EQUIPPED; i++) { tablist.add(inventory[EQUIPMENT].slots[i]); } for (int i = 0; i < MAX_CARRIED; i++) { tablist.add(inventory[CARRIED].slots[i]); } align(); }
MenuExit::MenuExit() : Menu() { buttonExit = new WidgetButton(); buttonClose = new WidgetButton(); // widgets for game options music_volume_sl = new WidgetSlider(); sound_volume_sl = new WidgetSlider(); // Load config settings FileParser infile; // @CLASS MenuExit|Description of menus/exit.txt if(infile.open("menus/exit.txt")) { while(infile.next()) { if (parseMenuKey(infile.key, infile.val)) continue; else if (infile.key == "title") { // @ATTR title|label|Position of the "Paused" text. title = eatLabelInfo(infile.val); } else if (infile.key == "exit") { // @ATTR exit|point|Position of the "Save and Exit" button. Point p = toPoint(infile.val); buttonExit->setBasePos(p.x, p.y); } else if (infile.key == "continue") { // @ATTR continue|point|Position of the "Continue" button. Point p = toPoint(infile.val); buttonClose->setBasePos(p.x, p.y); } else if (infile.key == "music_volume") { // @ATTR music_volume|int, int, int, int : Label X, Label Y, Widget X, Widget Y|Position of the "Music Volume" slider relative to the frame. Rect r = toRect(infile.val); placeOptionWidgets(&music_volume_lb, music_volume_sl, r.x, r.y, r.w, r.h, msg->get("Music Volume")); } else if (infile.key == "sound_volume") { // @ATTR sound_volume|int, int, int, int : Label X, Label Y, Widget X, Widget Y|Position of the "Sound Volume" slider relative to the frame. Rect r = toRect(infile.val); placeOptionWidgets(&sound_volume_lb, sound_volume_sl, r.x, r.y, r.w, r.h, msg->get("Sound Volume")); } else infile.error("MenuExit: '%s' is not a valid key.", infile.key.c_str()); } infile.close(); } exitClicked = false; reload_music = false; if (SAVE_ONEXIT) buttonExit->label = msg->get("Save & Exit"); else buttonExit->label = msg->get("Exit"); buttonClose->label = msg->get("Continue"); setBackground("images/menus/pause_menu.png"); if (AUDIO) { music_volume_sl->set(0, 128, MUSIC_VOLUME); sound_volume_sl->set(0, 128, SOUND_VOLUME); } else { music_volume_sl->set(0, 128, 0); sound_volume_sl->set(0, 128, 0); } tablist.add(buttonClose); tablist.add(buttonExit); tablist.add(music_volume_sl); tablist.add(sound_volume_sl); align(); }
MenuInventory::MenuInventory(StatBlock *_stats) : stats(_stats) , MAX_EQUIPPED(4) , MAX_CARRIED(64) , carried_cols(4) , carried_rows(4) , tap_to_activate_ticks(0) , currency(0) , drag_prev_src(-1) , changed_equipment(true) , inv_ctrl(INV_CTRL_NONE) , show_book("") { visible = false; setBackground("images/menus/inventory.png"); closeButton = new WidgetButton("images/menus/buttons/button_x.png"); // Load config settings FileParser infile; // @CLASS MenuInventory|Description of menus/inventory.txt if (infile.open("menus/inventory.txt")) { while(infile.next()) { if (parseMenuKey(infile.key, infile.val)) continue; // @ATTR close|point|Position of the close button. if(infile.key == "close") { Point pos = toPoint(infile.val); closeButton->setBasePos(pos.x, pos.y); } // @ATTR equipment_slot|repeatable(int, int, string) : X, Y, Slot Type|Position and item type of an equipment slot. else if(infile.key == "equipment_slot") { Rect area; Point pos; pos.x = area.x = popFirstInt(infile.val); pos.y = area.y = popFirstInt(infile.val); area.w = area.h = ICON_SIZE; equipped_area.push_back(area); equipped_pos.push_back(pos); slot_type.push_back(popFirstString(infile.val)); } // @ATTR carried_area|point|Position of the first normal inventory slot. else if(infile.key == "carried_area") { Point pos; carried_pos.x = carried_area.x = popFirstInt(infile.val); carried_pos.y = carried_area.y = popFirstInt(infile.val); } // @ATTR carried_cols|int|The number of columns for the normal inventory. else if (infile.key == "carried_cols") carried_cols = std::max(1, toInt(infile.val)); // @ATTR carried_rows|int|The number of rows for the normal inventory. else if (infile.key == "carried_rows") carried_rows = std::max(1, toInt(infile.val)); // @ATTR label_title|label|Position of the "Inventory" label. else if (infile.key == "label_title") title = eatLabelInfo(infile.val); // @ATTR currency|label|Position of the label that displays the total currency being carried. else if (infile.key == "currency") currency_lbl = eatLabelInfo(infile.val); // @ATTR help|rectangle|A mouse-over area that displays some help text for inventory shortcuts. else if (infile.key == "help") help_pos = toRect(infile.val); else infile.error("MenuInventory: '%s' is not a valid key.", infile.key.c_str()); } infile.close(); } MAX_EQUIPPED = static_cast<int>(equipped_area.size()); MAX_CARRIED = carried_cols * carried_rows; carried_area.w = carried_cols*ICON_SIZE; carried_area.h = carried_rows*ICON_SIZE; color_normal = font->getColor("menu_normal"); color_high = font->getColor("menu_bonus"); inventory[EQUIPMENT].initFromList(MAX_EQUIPPED, equipped_area, slot_type); inventory[CARRIED].initGrid(MAX_CARRIED, carried_area, carried_cols); for (int i = 0; i < MAX_EQUIPPED; i++) { tablist.add(inventory[EQUIPMENT].slots[i]); } for (int i = 0; i < MAX_CARRIED; i++) { tablist.add(inventory[CARRIED].slots[i]); } align(); }
void MenuBook::loadBook() { if (book_loaded) return; // Read data from config file FileParser infile; // @CLASS MenuBook|Description of books in books/ if (infile.open(book_name)) { while (infile.next()) { if (parseMenuKey(infile.key, infile.val)) continue; infile.val = infile.val + ','; // @ATTR close|x (integer), y (integer)|Position of the close button. if(infile.key == "close") { int x = popFirstInt(infile.val); int y = popFirstInt(infile.val); closeButton->setBasePos(x, y); } // @ATTR background|string|Filename for the background image. else if (infile.key == "background") { setBackground(popFirstString(infile.val)); } else if (infile.section == "") { infile.error("MenuBook: '%s' is not a valid key.", infile.key.c_str()); } if (infile.new_section) { // for sections that are stored in collections, add a new object here if (infile.section == "text") { text.push_back(NULL); textData.push_back(""); textColor.push_back(Color()); justify.push_back(0); textFont.push_back(""); size.push_back(Rect()); } else if (infile.section == "image") { image.push_back(NULL); image_dest.push_back(Point()); } } if (infile.section == "text") loadText(infile); else if (infile.section == "image") loadImage(infile); } infile.close(); } // setup image dest for (unsigned i=0; i < image.size(); i++) { image[i]->setDest(image_dest[i]); } // render text to surface for (unsigned i=0; i<text.size(); i++) { font->setFont(textFont[i]); Point pSize = font->calc_size(textData[i], size[i].w); Image *graphics = render_device->createImage(size[i].w, pSize.y); if (justify[i] == JUSTIFY_CENTER) font->render(textData[i], size[i].w/2, 0, justify[i], graphics, size[i].w, textColor[i]); else if (justify[i] == JUSTIFY_RIGHT) font->render(textData[i], size[i].w, 0, justify[i], graphics, size[i].w, textColor[i]); else font->render(textData[i], 0, 0, justify[i], graphics, size[i].w, textColor[i]); text[i] = graphics->createSprite(); graphics->unref(); } align(); book_loaded = true; }
MenuTalker::MenuTalker() : Menu() , portrait(NULL) , dialog_node(-1) , event_cursor(0) , first_interaction(false) , font_who("font_regular") , font_dialog("font_regular") , topic_color_normal(font->getColor(FontEngine::COLOR_MENU_BONUS)) , topic_color_hover(font->getColor(FontEngine::COLOR_WIDGET_NORMAL)) , topic_color_pressed(font->getColor(FontEngine::COLOR_WIDGET_DISABLED)) , trade_color_normal(font->getColor(FontEngine::COLOR_MENU_BONUS)) , trade_color_hover(font->getColor(FontEngine::COLOR_WIDGET_NORMAL)) , trade_color_pressed(font->getColor(FontEngine::COLOR_WIDGET_DISABLED)) , npc(NULL) , advanceButton(new WidgetButton("images/menus/buttons/right.png")) , closeButton(new WidgetButton("images/menus/buttons/button_x.png")) , npc_from_map(true) { setBackground("images/menus/dialog_box.png"); // Load config settings FileParser infile; // @CLASS MenuTalker|Description of menus/talker.txt if(infile.open("menus/talker.txt", FileParser::MOD_FILE, FileParser::ERROR_NORMAL)) { while(infile.next()) { if (parseMenuKey(infile.key, infile.val)) continue; // @ATTR close|point|Position of the close button. if(infile.key == "close") { Point pos = Parse::toPoint(infile.val); closeButton->setBasePos(pos.x, pos.y, Utils::ALIGN_TOPLEFT); } // @ATTR advance|point|Position of the button to advance dialog. else if(infile.key == "advance") { Point pos = Parse::toPoint(infile.val); advanceButton->setBasePos(pos.x, pos.y, Utils::ALIGN_TOPLEFT); } // @ATTR dialogbox|rectangle|Position and dimensions of the text box graphics. else if (infile.key == "dialogbox") dialog_pos = Parse::toRect(infile.val); // @ATTR dialogtext|rectangle|Rectangle where the dialog text is placed. else if (infile.key == "dialogtext") text_pos = Parse::toRect(infile.val); // @ATTR text_offset|point|Margins for the left/right and top/bottom of the dialog text. else if (infile.key == "text_offset") text_offset = Parse::toPoint(infile.val); // @ATTR portrait_he|rectangle|Position and dimensions of the NPC portrait graphics. else if (infile.key == "portrait_he") portrait_he = Parse::toRect(infile.val); // @ATTR portrait_you|rectangle|Position and dimensions of the player's portrait graphics. else if (infile.key == "portrait_you") portrait_you = Parse::toRect(infile.val); // @ATTR font_who|predefined_string|Font style to use for the name of the currently talking person. else if (infile.key == "font_who") font_who = infile.val; // @ATTR font_dialog|predefined_string|Font style to use for the dialog text. else if (infile.key == "font_dialog") font_dialog = infile.val; // @ATTR topic_color_normal|color|The normal color for topic text. else if (infile.key == "topic_color_normal") topic_color_normal = Parse::toRGB(infile.val); // @ATTR topic_color_hover|color|The color for topic text when highlighted. else if (infile.key == "topic_color_hover") topic_color_hover = Parse::toRGB(infile.val); // @ATTR topic_color_normal|color|The color for topic text when clicked. else if (infile.key == "topic_color_pressed") topic_color_pressed = Parse::toRGB(infile.val); // @ATTR trade_color_normal|color|The normal color for the "Trade" text. else if (infile.key == "trade_color_normal") trade_color_normal = Parse::toRGB(infile.val); // @ATTR trade_color_hover|color|The color for the "Trade" text when highlighted. else if (infile.key == "trade_color_hover") trade_color_hover = Parse::toRGB(infile.val); // @ATTR trade_color_normal|color|The color for the "Trade" text when clicked. else if (infile.key == "trade_color_pressed") trade_color_pressed = Parse::toRGB(infile.val); else infile.error("MenuTalker: '%s' is not a valid key.", infile.key.c_str()); } infile.close(); } label_name = new WidgetLabel(); label_name->setBasePos(text_pos.x + text_offset.x, text_pos.y + text_offset.y, Utils::ALIGN_TOPLEFT); label_name->setColor(font->getColor(FontEngine::COLOR_MENU_NORMAL)); textbox = new WidgetScrollBox(text_pos.w, text_pos.h-(text_offset.y*2)); textbox->setBasePos(text_pos.x, text_pos.y + text_offset.y, Utils::ALIGN_TOPLEFT); align(); }
MenuStash::MenuStash(StatBlock *_stats) : Menu() , stats(_stats) , closeButton(new WidgetButton("images/menus/buttons/button_x.png")) , color_normal(font->getColor("menu_normal")) , stock() , updated(false) { setBackground("images/menus/stash.png"); slots_cols = 8; // default if menus/stash.txt::stash_cols not set slots_rows = 8; // default if menus/stash.txt::slots_rows not set // Load config settings FileParser infile; // @CLASS MenuStash|Description of menus/stash.txt if (infile.open("menus/stash.txt")) { while(infile.next()) { if (parseMenuKey(infile.key, infile.val)) continue; // @ATTR close|x (integer), y (integer)|Position of the close button. if (infile.key == "close") { Point pos = toPoint(infile.val); closeButton->setBasePos(pos.x, pos.y); } // @ATTR slots_area|x (integer), y (integer)|Position of the top-left slot. else if (infile.key == "slots_area") { slots_area.x = popFirstInt(infile.val); slots_area.y = popFirstInt(infile.val); } // @ATTR stash_cols|integer|The number of columns for the grid of slots. else if (infile.key == "stash_cols") { slots_cols = std::max(1, toInt(infile.val)); } // @ATTR stash_rows|integer|The number of rows for the grid of slots. else if (infile.key == "stash_rows") { slots_rows = std::max(1, toInt(infile.val)); } // @ATTR label_title|label|Position of the "Stash" label. else if (infile.key == "label_title") { title = eatLabelInfo(infile.val); } // @ATTR currency|label|Position of the label displaying the amount of currency stored in the stash. else if (infile.key == "currency") { currency = eatLabelInfo(infile.val); } else { infile.error("MenuStash: '%s' is not a valid key.", infile.key.c_str()); } } infile.close(); } STASH_SLOTS = slots_cols * slots_rows; slots_area.w = slots_cols*ICON_SIZE; slots_area.h = slots_rows*ICON_SIZE; stock.init( STASH_SLOTS, slots_area, ICON_SIZE, slots_cols); for (int i = 0; i < STASH_SLOTS; i++) { tablist.add(stock.slots[i]); } align(); }
MenuStatBar::MenuStatBar(short _type) : bar(NULL) , label(new WidgetLabel()) , stat_min(0) , stat_cur(0) , stat_cur_prev(0) , stat_max(0) , orientation(HORIZONTAL) , custom_text_pos(false) // label will be placed in the middle of the bar , custom_string("") , bar_gfx("") , bar_gfx_background("") , type(_type) { std::string type_filename; if (type == TYPE_HP) type_filename = "hp"; else if (type == TYPE_MP) type_filename = "mp"; else if (type == TYPE_XP) type_filename = "xp"; // Load config settings FileParser infile; // @CLASS MenuStatBar|Description of menus/hp.txt, menus/mp.txt, menus/xp.txt if(!type_filename.empty() && infile.open("menus/" + type_filename + ".txt", FileParser::MOD_FILE, FileParser::ERROR_NORMAL)) { while(infile.next()) { if (parseMenuKey(infile.key, infile.val)) continue; // @ATTR bar_pos|rectangle|Position and dimensions of the bar graphics. if(infile.key == "bar_pos") { bar_pos = Parse::toRect(infile.val); } // @ATTR text_pos|label|Position of the text displaying the current value of the relevant stat. else if(infile.key == "text_pos") { custom_text_pos = true; text_pos = Parse::popLabelInfo(infile.val); } // @ATTR orientation|bool|True is vertical orientation; false is horizontal. else if(infile.key == "orientation") { orientation = Parse::toBool(infile.val); } // @ATTR bar_gfx|filename|Filename of the image to use for the "fill" of the bar. else if (infile.key == "bar_gfx") { bar_gfx = infile.val; } // @ATTR bar_gfx_background|filename|Filename of the image to use for the base of the bar. else if (infile.key == "bar_gfx_background") { bar_gfx_background = infile.val; } // @ATTR hide_timeout|duration|Hide HP and MP bar if full mana or health, after given amount of seconds; Hide XP bar if no changes in XP points for given amount of seconds. 0 disable hiding. else if (infile.key == "hide_timeout") { timeout.setDuration(Parse::toDuration(infile.val)); } else { infile.error("MenuStatBar: '%s' is not a valid key.", infile.key.c_str()); } } infile.close(); } loadGraphics(); align(); }