MenuBook::MenuBook() : book_name("") , book_loaded(false) { closeButton = new WidgetButton("images/menus/buttons/button_x.png"); tablist = TabList(); tablist.add(closeButton); }
WidgetScrollBox::WidgetScrollBox(int width, int height) : contents(NULL) { pos.x = pos.y = 0; pos.w = width; pos.h = height; cursor = 0; bg.r = bg.g = bg.b = 0; currentChild = -1; scrollbar = new WidgetScrollBar(); update = true; render_to_alpha = false; transparent = true; line_height = 20; resize(width, height); tablist = TabList(VERTICAL); }
GameStateLoad::GameStateLoad() : GameState() , background(NULL) , selection(NULL) , portrait_border(NULL) , portrait(NULL) , loading_requested(false) , loading(false) , loaded(false) , delete_items(true) , selected_slot(-1) , visible_slots(0) , scroll_offset(0) , has_scroll_bar(false) , game_slot_max(4) , text_trim_boundary(0) { if (items == NULL) items = new ItemManager(); label_loading = new WidgetLabel(); // Confirmation box to confirm deleting confirm = new MenuConfirm(msg->get("Delete Save"), msg->get("Delete this save?")); button_exit = new WidgetButton(); button_exit->label = msg->get("Exit to Title"); button_new = new WidgetButton(); button_new->label = msg->get("New Game"); button_new->enabled = true; button_load = new WidgetButton(); button_load->label = msg->get("Choose a Slot"); button_load->enabled = false; button_delete = new WidgetButton(); button_delete->label = msg->get("Delete Save"); button_delete->enabled = false; scrollbar = new WidgetScrollBar(); // Set up tab list tablist = TabList(HORIZONTAL); tablist.add(button_exit); tablist.add(button_new); // Read positions from config file FileParser infile; // @CLASS GameStateLoad|Description of menus/gameload.txt if (infile.open("menus/gameload.txt")) { while (infile.next()) { // @ATTR button_new|int, int, alignment : X, Y, Alignment|Position of the "New Game" button. if (infile.key == "button_new") { int x = popFirstInt(infile.val); int y = popFirstInt(infile.val); ALIGNMENT a = parse_alignment(popFirstString(infile.val)); button_new->setBasePos(x, y, a); } // @ATTR button_load|int, int, alignment : X, Y, Alignment|Position of the "Load Game" button. else if (infile.key == "button_load") { int x = popFirstInt(infile.val); int y = popFirstInt(infile.val); ALIGNMENT a = parse_alignment(popFirstString(infile.val)); button_load->setBasePos(x, y, a); } // @ATTR button_delete|int, int, alignment : X, Y, Alignment|Position of the "Delete Save" button. else if (infile.key == "button_delete") { int x = popFirstInt(infile.val); int y = popFirstInt(infile.val); ALIGNMENT a = parse_alignment(popFirstString(infile.val)); button_delete->setBasePos(x, y, a); } // @ATTR button_exit|int, int, alignment : X, Y, Alignment|Position of the "Exit to Title" button. else if (infile.key == "button_exit") { int x = popFirstInt(infile.val); int y = popFirstInt(infile.val); ALIGNMENT a = parse_alignment(popFirstString(infile.val)); button_exit->setBasePos(x, y, a); } // @ATTR portrait|rectangle|Position and dimensions of the portrait image. else if (infile.key == "portrait") { portrait_dest = toRect(infile.val); } // @ATTR gameslot|rectangle|Position and dimensions of the first game slot. else if (infile.key == "gameslot") { gameslot_pos = toRect(infile.val); } // @ATTR name|label|The label for the hero's name. Position is relative to game slot position. else if (infile.key == "name") { name_pos = eatLabelInfo(infile.val); } // @ATTR level|label|The label for the hero's level. Position is relative to game slot position. else if (infile.key == "level") { level_pos = eatLabelInfo(infile.val); } // @ATTR class|label|The label for the hero's class. Position is relative to game slot position. else if (infile.key == "class") { class_pos = eatLabelInfo(infile.val); } // @ATTR map|label|The label for the hero's current location. Position is relative to game slot position. else if (infile.key == "map") { map_pos = eatLabelInfo(infile.val); } // @ATTR slot_number|label|The label for the save slot index. Position is relative to game slot position. else if (infile.key == "slot_number") { slot_number_pos = eatLabelInfo(infile.val); } // @ATTR loading_label|label|The label for the "Entering game world..."/"Loading saved game..." text. else if (infile.key == "loading_label") { loading_pos = eatLabelInfo(infile.val); } // @ATTR sprite|point|Position for the avatar preview image in each slot else if (infile.key == "sprite") { sprites_pos = toPoint(infile.val); } // @ATTR visible_slots|int|The maximum numbers of visible save slots. else if (infile.key == "visible_slots") { game_slot_max = toInt(infile.val); // can't have less than 1 game slot visible game_slot_max = std::max(game_slot_max, 1); } // @ATTR text_trim_boundary|int|The position of the right-side boundary where text will be shortened with an ellipsis. Position is relative to game slot position. else if (infile.key == "text_trim_boundary") { text_trim_boundary = toInt(infile.val); } else { infile.error("GameStateLoad: '%s' is not a valid key.", infile.key.c_str()); } } infile.close(); } // prevent text from overflowing on the right edge of game slots if (text_trim_boundary == 0 || text_trim_boundary > gameslot_pos.w) text_trim_boundary = gameslot_pos.w; button_new->refresh(); button_load->refresh(); button_delete->refresh(); loadGraphics(); readGameSlots(); color_normal = font->getColor("menu_normal"); refreshWidgets(); updateButtons(); // if we specified a slot to load at launch, load it now if (!LOAD_SLOT.empty()) { size_t load_slot_id = toInt(LOAD_SLOT) - 1; LOAD_SLOT.clear(); if (load_slot_id < game_slots.size()) { setSelectedSlot(static_cast<int>(load_slot_id)); loading_requested = true; } } render_device->setBackgroundColor(Color(0,0,0,0)); }
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; }