From 7e4eabf198bacba3de71906a6bcc880aab44d301 Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Mon, 1 Jun 2015 18:59:24 -0400 Subject: [PATCH] Add item-monster selection palette which fills the same space as the terrain palette - Removed the item/monster menus in the scenario editor (they weren't function anyway) - Scrollbars can now have a maximum value of 0; if this is the case, they do not draw a thumb --- src/BoE.vsproj/ScenEdit/Scen Editor.rc | 36 ---- src/classes/town.cpp | 2 +- src/dialogxml/scrollbar.cpp | 19 +- src/scenedit/scen.actions.cpp | 38 +++- src/scenedit/scen.core.cpp | 1 - src/scenedit/scen.graphics.cpp | 257 +++++++++++++++++++++-- src/scenedit/scen.graphics.h | 1 - src/scenedit/scen.main.cpp | 17 -- src/scenedit/scen.menu.xib | 278 ------------------------- src/scenedit/scen.menus.h | 3 - src/scenedit/scen.menus.mac.mm | 71 ------- src/scenedit/scen.menus.win.cpp | 40 +--- 12 files changed, 285 insertions(+), 478 deletions(-) diff --git a/src/BoE.vsproj/ScenEdit/Scen Editor.rc b/src/BoE.vsproj/ScenEdit/Scen Editor.rc index 9df5a641..bd359d48 100644 --- a/src/BoE.vsproj/ScenEdit/Scen Editor.rc +++ b/src/BoE.vsproj/ScenEdit/Scen Editor.rc @@ -168,42 +168,6 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Repeat Printing of Last &File\tCtrl+P", 414 END - POPUP "&I1" - BEGIN - MENUITEM "Dummy", 600 - END - POPUP "&I2" - BEGIN - MENUITEM "Dummy", 601 - END - POPUP "&I3" - BEGIN - MENUITEM "Dummy", 602 - END - POPUP "&I4" - BEGIN - MENUITEM "Dummy", 603 - END - POPUP "&I5" - BEGIN - MENUITEM "Dummy", 604 - END - POPUP "&M1" - BEGIN - MENUITEM "Dummy", 608 - END - POPUP "&M2" - BEGIN - MENUITEM "Dummy", 609 - END - POPUP "&M3" - BEGIN - MENUITEM "Dummy", 610 - END - POPUP "&M4" - BEGIN - MENUITEM "Dummy", 611 - END POPUP "&Help" BEGIN MENUITEM "&Index\tF1", IDM_HELP_INDEX diff --git a/src/classes/town.cpp b/src/classes/town.cpp index de563a47..0eae8af3 100644 --- a/src/classes/town.cpp +++ b/src/classes/town.cpp @@ -259,7 +259,7 @@ cTown::cItem::cItem() { } cTown::cItem::cItem(location loc, short num, ::cItem& item) : cItem() { - loc = loc; + this->loc = loc; code = num; if(item.variety == eItemType::GOLD || item.variety == eItemType::FOOD) charges = get_ran(1,4,6); diff --git a/src/dialogxml/scrollbar.cpp b/src/dialogxml/scrollbar.cpp index a1f5a24f..dea33fed 100644 --- a/src/dialogxml/scrollbar.cpp +++ b/src/dialogxml/scrollbar.cpp @@ -30,7 +30,7 @@ void cScrollbar::setPosition(long newPos) { } void cScrollbar::setMaximum(long newMax) { - max = ::max(1,newMax); + max = ::max(0,newMax); setPosition(pos); } @@ -65,6 +65,7 @@ bool cScrollbar::triggerClickHandler(cDialog& me, std::string id, eKeyMod mods) } bool cScrollbar::handleClick(location where) { + if(max == 0) return false; sf::Event e; bool done = false, clicked = false; inWindow->setActive(); @@ -172,13 +173,15 @@ void cScrollbar::draw() { } draw_rect.bottom = top + height; } - draw_rect.top = draw_rect.bottom; - draw_rect.height() = 16; - from_rect = thumb_rect; - if(depressed && pressedPart == PART_THUMB) - from_rect.offset(0,16); - rect_draw_some_item(scroll_gw, from_rect, *inWindow, draw_rect); - if(pos < max) { + if(max > 0) { + draw_rect.top = draw_rect.bottom; + draw_rect.height() = 16; + from_rect = thumb_rect; + if(depressed && pressedPart == PART_THUMB) + from_rect.offset(0,16); + rect_draw_some_item(scroll_gw, from_rect, *inWindow, draw_rect); + } + if(pos < max || max == 0) { from_rect = bar_rect; int top = draw_rect.bottom, bottom = frame.bottom - 16; if(depressed && pressedPart == PART_PGDN) diff --git a/src/scenedit/scen.actions.cpp b/src/scenedit/scen.actions.cpp index bea297b8..f20f078d 100644 --- a/src/scenedit/scen.actions.cpp +++ b/src/scenedit/scen.actions.cpp @@ -26,6 +26,7 @@ extern char current_string[256]; extern short mini_map_scales[3]; +extern eDrawMode draw_mode; rectangle world_screen; // border rects order: top, left, bottom, right // rectangle border_rect[4]; @@ -202,7 +203,6 @@ bool handle_action(location the_point,sf::Event /*event*/) { current_terrain = scenario.outdoors[cur_out.x][cur_out.y]; overall_mode = MODE_MAIN_SCREEN; set_up_main_screen(); - update_item_menu(); } break; case LB_EDIT_TER: @@ -309,16 +309,13 @@ bool handle_action(location the_point,sf::Event /*event*/) { break; case RB_TER: edit_ter_type(j); - update_item_menu(); break; case RB_MONST: edit_monst_type(j); - update_item_menu(); start_monster_editing(1); break; case RB_ITEM: edit_item_type(j); - update_item_menu(); start_item_editing(1); break; case RB_SCEN_SPEC: @@ -997,7 +994,25 @@ bool handle_action(location the_point,sf::Event /*event*/) { temp_rect.offset(RIGHT_AREA_UL_X, RIGHT_AREA_UL_Y ); flash_rect(temp_rect); if(overall_mode < MODE_MAIN_SCREEN) { - set_new_terrain(i); + switch(draw_mode) { + case DRAW_TERRAIN: + set_new_terrain(i); + break; + case DRAW_ITEM: + if(scenario.scen_items[mode_count].variety == eItemType::NO_ITEM) { + giveError("This item has its Variety set to No Item. You can only place items with a Variety set to an actual item type."); + break; + } + overall_mode = MODE_PLACE_ITEM; + mode_count = i; + set_string("Place the item:",scenario.scen_items[mode_count].full_name.c_str()); + break; + case DRAW_MONST: + overall_mode = MODE_PLACE_CREATURE; + mode_count = i + 1; + set_string("Place the monster:",scenario.scen_monsters[mode_count].m_name.c_str()); + break; + } } else { edit_ter_type(i); @@ -1274,6 +1289,18 @@ bool handle_action(location the_point,sf::Event /*event*/) { mode_count = 7; set_cursor(wand_curs); break; + case 109: // Terrain palette + draw_mode = DRAW_TERRAIN; + set_up_terrain_buttons(true); + break; + case 209: // Item palette + draw_mode = DRAW_ITEM; + set_up_terrain_buttons(true); + break; + case 309: // Monster palette + draw_mode = DRAW_MONST; + set_up_terrain_buttons(true); + break; } } } @@ -1317,7 +1344,6 @@ void swap_terrain() { void set_new_terrain(ter_num_t selected_terrain) { current_terrain_type = selected_terrain; - redraw_selected_ter(); // if(selected_terrain < 2) // current_ground = 0; // else if(selected_terrain < 5) diff --git a/src/scenedit/scen.core.cpp b/src/scenedit/scen.core.cpp index 129f40e4..3509e9ad 100644 --- a/src/scenedit/scen.core.cpp +++ b/src/scenedit/scen.core.cpp @@ -3016,7 +3016,6 @@ bool build_scenario() { } cur_town = 0; town = scenario.towns[0]; - update_item_menu(); save_scenario(progDir/filename); return true; diff --git a/src/scenedit/scen.graphics.cpp b/src/scenedit/scen.graphics.cpp index f7547be3..b2b1b8c6 100644 --- a/src/scenedit/scen.graphics.cpp +++ b/src/scenedit/scen.graphics.cpp @@ -489,21 +489,27 @@ void set_up_terrain_buttons(bool reset) { rectangle tiny_from,tiny_to; rectangle palette_from,palette_to = palette_button_base; + int max; + switch(draw_mode) { + case DRAW_TERRAIN: max = scenario.ter_types.size(); break; + case DRAW_ITEM: max = scenario.scen_items.size(); break; + case DRAW_MONST: max = scenario.scen_monsters.size(); break; + default: return; + } if(reset) pal_sbar->setPosition(0); - pal_sbar->setMaximum((scenario.ter_types.size() / 16) - 15); - if(overall_mode != MODE_EDIT_TYPES) - pal_sbar->setMaximum(pal_sbar->getMaximum() - 1); + pal_sbar->setMaximum((max / 16) - 16); tileImage(terrain_buttons_gworld,terrain_buttons_rect,bg[17]); frame_rect(terrain_buttons_gworld, terrain_buttons_rect, sf::Color::Black); int first = pal_sbar->getPosition() * 16; - int end = min(first + 256, scenario.ter_types.size()); + if(draw_mode == DRAW_MONST) first++; + int end = min(first + 256, max); // first make terrain buttons - switch(draw_mode){ - case DRAW_TERRAIN: - for(i = first; i < end; i++) { + for(i = first; i < end; i++) { + switch(draw_mode){ + case DRAW_TERRAIN: ter_from = ter_from_base; pic = scenario.ter_types[i].picture; if(pic >= 1000) { @@ -536,12 +542,119 @@ void set_up_terrain_buttons(bool reset) { tiny_to.left = tiny_to.right - 7; if(small_i > 0 && small_i < 255) rect_draw_some_item(editor_mixed,tiny_from,terrain_buttons_gworld,tiny_to); - } - break; - case DRAW_MONST: - break; - case DRAW_ITEM: - break; + break; + case DRAW_MONST: + pic = scenario.scen_monsters[i].picture_num; + tiny_to = terrain_rects[i - first]; + frame_rect(terrain_buttons_gworld, tiny_to, sf::Color::Black); + if(pic >= 4000) { + pic %= 1000; + tiny_to.width() = tiny_to.width() / 2; + tiny_to.height() = tiny_to.height() / 2; + sf::Texture* source_gworld; + graf_pos_ref(source_gworld, ter_from) = spec_scen_g.find_graphic(pic); + rect_draw_some_item(*source_gworld, ter_from, terrain_buttons_gworld, tiny_to, sf::BlendAlpha); + pic++; + tiny_to.offset(tiny_to.width(), 0); + graf_pos_ref(source_gworld, ter_from) = spec_scen_g.find_graphic(pic); + rect_draw_some_item(*source_gworld, ter_from, terrain_buttons_gworld, tiny_to, sf::BlendAlpha); + pic++; + tiny_to.offset(-tiny_to.width(), tiny_to.height()); + graf_pos_ref(source_gworld, ter_from) = spec_scen_g.find_graphic(pic); + rect_draw_some_item(*source_gworld, ter_from, terrain_buttons_gworld, tiny_to, sf::BlendAlpha); + pic++; + tiny_to.offset(tiny_to.width(), 0); + graf_pos_ref(source_gworld, ter_from) = spec_scen_g.find_graphic(pic); + rect_draw_some_item(*source_gworld, ter_from, terrain_buttons_gworld, tiny_to, sf::BlendAlpha); + } else if(pic >= 3000) { + pic %= 1000; + tiny_to.width() = tiny_to.width() / 2; + tiny_to.height() = tiny_to.height() / 2; + tiny_to.offset(tiny_to.width() / 2, 0); + sf::Texture* source_gworld; + graf_pos_ref(source_gworld, ter_from) = spec_scen_g.find_graphic(pic); + rect_draw_some_item(*source_gworld, ter_from, terrain_buttons_gworld, tiny_to, sf::BlendAlpha); + pic++; + tiny_to.offset(0, tiny_to.height()); + graf_pos_ref(source_gworld, ter_from) = spec_scen_g.find_graphic(pic); + rect_draw_some_item(*source_gworld, ter_from, terrain_buttons_gworld, tiny_to, sf::BlendAlpha); + } else if(pic >= 2000) { + pic %= 1000; + tiny_to.width() = tiny_to.width() / 2; + tiny_to.height() = tiny_to.height() / 2; + tiny_to.offset(0, tiny_to.height() / 2); + sf::Texture* source_gworld; + graf_pos_ref(source_gworld, ter_from) = spec_scen_g.find_graphic(pic); + rect_draw_some_item(*source_gworld, ter_from, terrain_buttons_gworld, tiny_to, sf::BlendAlpha); + pic++; + tiny_to.offset(tiny_to.width(), 0); + graf_pos_ref(source_gworld, ter_from) = spec_scen_g.find_graphic(pic); + rect_draw_some_item(*source_gworld, ter_from, terrain_buttons_gworld, tiny_to, sf::BlendAlpha); + } else if(pic >= 1000) { + pic %= 1000; + sf::Texture* source_gworld; + graf_pos_ref(source_gworld, ter_from) = spec_scen_g.find_graphic(pic); + rect_draw_some_item(*source_gworld, ter_from, terrain_buttons_gworld, tiny_to, sf::BlendAlpha); + } else { + auto pic_info = m_pic_index[pic]; + pic = pic_info.i; + if(pic_info.x == 2 && pic_info.y == 2) { + tiny_to.width() = tiny_to.width() / 2; + tiny_to.height() = tiny_to.height() / 2; + ter_from = calc_rect(2 * ((pic % 20) / 10), (pic % 20) % 10); + rect_draw_some_item(monst_gworld[pic / 20], ter_from, terrain_buttons_gworld, tiny_to, sf::BlendAlpha); + pic++; + tiny_to.offset(tiny_to.width(), 0); + ter_from = calc_rect(2 * ((pic % 20) / 10), (pic % 20) % 10); + rect_draw_some_item(monst_gworld[pic / 20], ter_from, terrain_buttons_gworld, tiny_to, sf::BlendAlpha); + pic++; + tiny_to.offset(-tiny_to.width(), tiny_to.height()); + ter_from = calc_rect(2 * ((pic % 20) / 10), (pic % 20) % 10); + rect_draw_some_item(monst_gworld[pic / 20], ter_from, terrain_buttons_gworld, tiny_to, sf::BlendAlpha); + pic++; + tiny_to.offset(tiny_to.width(), 0); + ter_from = calc_rect(2 * ((pic % 20) / 10), (pic % 20) % 10); + rect_draw_some_item(monst_gworld[pic / 20], ter_from, terrain_buttons_gworld, tiny_to, sf::BlendAlpha); + } else if(pic_info.y == 2) { + tiny_to.width() = tiny_to.width() / 2; + tiny_to.height() = tiny_to.height() / 2; + tiny_to.offset(tiny_to.width() / 2, 0); + ter_from = calc_rect(2 * ((pic % 20) / 10), (pic % 20) % 10); + rect_draw_some_item(monst_gworld[pic / 20], ter_from, terrain_buttons_gworld, tiny_to, sf::BlendAlpha); + pic++; + tiny_to.offset(0, tiny_to.height()); + ter_from = calc_rect(2 * ((pic % 20) / 10), (pic % 20) % 10); + rect_draw_some_item(monst_gworld[pic / 20], ter_from, terrain_buttons_gworld, tiny_to, sf::BlendAlpha); + } else if(pic_info.x == 2) { + tiny_to.width() = tiny_to.width() / 2; + tiny_to.height() = tiny_to.height() / 2; + tiny_to.offset(0, tiny_to.height() / 2); + ter_from = calc_rect(2 * ((pic % 20) / 10), (pic % 20) % 10); + rect_draw_some_item(monst_gworld[pic / 20], ter_from, terrain_buttons_gworld, tiny_to, sf::BlendAlpha); + pic++; + tiny_to.offset(tiny_to.width(), 0); + ter_from = calc_rect(2 * ((pic % 20) / 10), (pic % 20) % 10); + rect_draw_some_item(monst_gworld[pic / 20], ter_from, terrain_buttons_gworld, tiny_to, sf::BlendAlpha); + } else { + ter_from = calc_rect(2 * ((pic % 20) / 10), (pic % 20) % 10); + rect_draw_some_item(monst_gworld[pic / 20], ter_from, terrain_buttons_gworld, tiny_to, sf::BlendAlpha); + } + } + break; + case DRAW_ITEM: + pic = scenario.scen_items[i].graphic_num; + tiny_to = terrain_rects[i - first]; + if(pic >= 1000) { + sf::Texture* source_gworld; + graf_pos_ref(source_gworld, ter_from) = spec_scen_g.find_graphic(pic % 1000); + rect_draw_some_item(*source_gworld,ter_from,terrain_buttons_gworld,tiny_to,sf::BlendAlpha); + } else { + tiny_from = {0,0,18,18}; + tiny_from.offset((pic % 10) * 18,(pic / 10) * 18); + rect_draw_some_item(tiny_obj_gworld,tiny_from,terrain_buttons_gworld,tiny_to,sf::BlendAlpha); + } + break; + } } if(overall_mode < MODE_MAIN_SCREEN) { @@ -960,10 +1073,6 @@ void force_tiny_redraw() { } -void redraw_selected_ter() { - // draw_one_terrain_spot(18,8,(unsigned char) current_terrain_type); -} - void draw_one_terrain_spot (short i,short j,ter_num_t terrain_to_draw) { location where_draw; rectangle source_rect; @@ -1220,6 +1329,120 @@ void place_location() { tiny_from.offset(7 * (small_i % 10),7 * (small_i / 10)); if(small_i > 0 && small_i < 255) rect_draw_some_item(editor_mixed,tiny_from,terrain_buttons_gworld,tiny_to); + if(overall_mode == MODE_PLACE_CREATURE || overall_mode == MODE_PLACE_SAME_CREATURE) { + extern short mode_count; + picture_wanted = scenario.scen_monsters[mode_count].picture_num; + if(picture_wanted >= 4000) { + picture_wanted %= 1000; + tiny_to.width() = tiny_to.width() / 2; + tiny_to.height() = tiny_to.height() / 2; + sf::Texture* source_gworld; + graf_pos_ref(source_gworld, source_rect) = spec_scen_g.find_graphic(picture_wanted); + rect_draw_some_item(*source_gworld, source_rect, terrain_buttons_gworld, draw_rect, sf::BlendAlpha); + picture_wanted++; + tiny_to.offset(tiny_to.width(), 0); + graf_pos_ref(source_gworld, source_rect) = spec_scen_g.find_graphic(picture_wanted); + rect_draw_some_item(*source_gworld, source_rect, terrain_buttons_gworld, draw_rect, sf::BlendAlpha); + picture_wanted++; + tiny_to.offset(-tiny_to.width(), tiny_to.height()); + graf_pos_ref(source_gworld, source_rect) = spec_scen_g.find_graphic(picture_wanted); + rect_draw_some_item(*source_gworld, source_rect, terrain_buttons_gworld, draw_rect, sf::BlendAlpha); + picture_wanted++; + tiny_to.offset(tiny_to.width(), 0); + graf_pos_ref(source_gworld, source_rect) = spec_scen_g.find_graphic(picture_wanted); + rect_draw_some_item(*source_gworld, source_rect, terrain_buttons_gworld, draw_rect, sf::BlendAlpha); + } else if(picture_wanted >= 3000) { + picture_wanted %= 1000; + tiny_to.width() = tiny_to.width() / 2; + tiny_to.height() = tiny_to.height() / 2; + tiny_to.offset(tiny_to.width() / 2, 0); + sf::Texture* source_gworld; + graf_pos_ref(source_gworld, source_rect) = spec_scen_g.find_graphic(picture_wanted); + rect_draw_some_item(*source_gworld, source_rect, terrain_buttons_gworld, draw_rect, sf::BlendAlpha); + picture_wanted++; + tiny_to.offset(0, tiny_to.height()); + graf_pos_ref(source_gworld, source_rect) = spec_scen_g.find_graphic(picture_wanted); + rect_draw_some_item(*source_gworld, source_rect, terrain_buttons_gworld, draw_rect, sf::BlendAlpha); + } else if(picture_wanted >= 2000) { + picture_wanted %= 1000; + tiny_to.width() = tiny_to.width() / 2; + tiny_to.height() = tiny_to.height() / 2; + tiny_to.offset(0, tiny_to.height() / 2); + sf::Texture* source_gworld; + graf_pos_ref(source_gworld, source_rect) = spec_scen_g.find_graphic(picture_wanted); + rect_draw_some_item(*source_gworld, source_rect, terrain_buttons_gworld, draw_rect, sf::BlendAlpha); + picture_wanted++; + tiny_to.offset(tiny_to.width(), 0); + graf_pos_ref(source_gworld, source_rect) = spec_scen_g.find_graphic(picture_wanted); + rect_draw_some_item(*source_gworld, source_rect, terrain_buttons_gworld, draw_rect, sf::BlendAlpha); + } else if(picture_wanted >= 1000) { + picture_wanted %= 1000; + sf::Texture* source_gworld; + graf_pos_ref(source_gworld, source_rect) = spec_scen_g.find_graphic(picture_wanted); + rect_draw_some_item(*source_gworld, source_rect, terrain_buttons_gworld, draw_rect, sf::BlendAlpha); + } else { + auto pic_info = m_pic_index[picture_wanted]; + picture_wanted = pic_info.i; + if(pic_info.x == 2 && pic_info.y == 2) { + tiny_to.width() = tiny_to.width() / 2; + tiny_to.height() = tiny_to.height() / 2; + source_rect = calc_rect(2 * ((picture_wanted % 20) / 10), (picture_wanted % 20) % 10); + rect_draw_some_item(monst_gworld[picture_wanted / 20], source_rect, terrain_buttons_gworld, draw_rect, sf::BlendAlpha); + picture_wanted++; + tiny_to.offset(tiny_to.width(), 0); + source_rect = calc_rect(2 * ((picture_wanted % 20) / 10), (picture_wanted % 20) % 10); + rect_draw_some_item(monst_gworld[picture_wanted / 20], source_rect, terrain_buttons_gworld, draw_rect, sf::BlendAlpha); + picture_wanted++; + tiny_to.offset(-tiny_to.width(), tiny_to.height()); + source_rect = calc_rect(2 * ((picture_wanted % 20) / 10), (picture_wanted % 20) % 10); + rect_draw_some_item(monst_gworld[picture_wanted / 20], source_rect, terrain_buttons_gworld, draw_rect, sf::BlendAlpha); + picture_wanted++; + tiny_to.offset(tiny_to.width(), 0); + source_rect = calc_rect(2 * ((picture_wanted % 20) / 10), (picture_wanted % 20) % 10); + rect_draw_some_item(monst_gworld[picture_wanted / 20], source_rect, terrain_buttons_gworld, draw_rect, sf::BlendAlpha); + } else if(pic_info.y == 2) { + tiny_to.width() = tiny_to.width() / 2; + tiny_to.height() = tiny_to.height() / 2; + tiny_to.offset(tiny_to.width() / 2, 0); + source_rect = calc_rect(2 * ((picture_wanted % 20) / 10), (picture_wanted % 20) % 10); + rect_draw_some_item(monst_gworld[picture_wanted / 20], source_rect, terrain_buttons_gworld, draw_rect, sf::BlendAlpha); + picture_wanted++; + tiny_to.offset(0, tiny_to.height()); + source_rect = calc_rect(2 * ((picture_wanted % 20) / 10), (picture_wanted % 20) % 10); + rect_draw_some_item(monst_gworld[picture_wanted / 20], source_rect, terrain_buttons_gworld, draw_rect, sf::BlendAlpha); + } else if(pic_info.x == 2) { + tiny_to.width() = tiny_to.width() / 2; + tiny_to.height() = tiny_to.height() / 2; + tiny_to.offset(0, tiny_to.height() / 2); + source_rect = calc_rect(2 * ((picture_wanted % 20) / 10), (picture_wanted % 20) % 10); + rect_draw_some_item(monst_gworld[picture_wanted / 20], source_rect, terrain_buttons_gworld, draw_rect, sf::BlendAlpha); + picture_wanted++; + tiny_to.offset(tiny_to.width(), 0); + source_rect = calc_rect(2 * ((picture_wanted % 20) / 10), (picture_wanted % 20) % 10); + rect_draw_some_item(monst_gworld[picture_wanted / 20], source_rect, terrain_buttons_gworld, draw_rect, sf::BlendAlpha); + } else { + source_rect = calc_rect(2 * ((picture_wanted % 20) / 10), (picture_wanted % 20) % 10); + rect_draw_some_item(monst_gworld[picture_wanted / 20], source_rect, terrain_buttons_gworld, draw_rect, sf::BlendAlpha); + } + } + } else if(overall_mode == MODE_PLACE_ITEM || overall_mode == MODE_PLACE_SAME_ITEM) { + extern short mode_count; + picture_wanted = scenario.scen_items[mode_count].graphic_num; + if(picture_wanted >= 1000) { + sf::Texture* source_gworld; + graf_pos_ref(source_gworld, source_rect) = spec_scen_g.find_graphic(picture_wanted % 1000); + rect_draw_some_item(*source_gworld,source_rect,terrain_buttons_gworld,draw_rect,sf::BlendAlpha); + } else if(picture_wanted < 50) { + source_rect = calc_rect(picture_wanted % 5,picture_wanted / 5); + rect_draw_some_item(items_gworld,source_rect,terrain_buttons_gworld,draw_rect,sf::BlendAlpha); + } else { + tiny_to = draw_rect; + tiny_to.inset(5, 9); + tiny_from = {0,0,18,18}; + tiny_from.offset((picture_wanted % 10) * 18,(picture_wanted / 10) * 18); + rect_draw_some_item(tiny_obj_gworld,tiny_from,terrain_buttons_gworld,tiny_to,sf::BlendAlpha); + } + } } terrain_buttons_gworld.display(); diff --git a/src/scenedit/scen.graphics.h b/src/scenedit/scen.graphics.h index 9554d619..9c6f327c 100644 --- a/src/scenedit/scen.graphics.h +++ b/src/scenedit/scen.graphics.h @@ -17,7 +17,6 @@ void draw_monsts(); rectangle get_item_template_rect (short type_wanted); void draw_items(); void force_tiny_redraw(); -void redraw_selected_ter(); void draw_one_terrain_spot (short i,short j,ter_num_t terrain_to_draw); void draw_one_tiny_terrain_spot (short i,short j,ter_num_t terrain_to_draw,short size); void Draw_Some_Item(sf::Texture& src_gworld,rectangle src_rect,sf::RenderTarget& targ_gworld,location target,sf::BlendMode mode = sf::BlendNone); diff --git a/src/scenedit/scen.main.cpp b/src/scenedit/scen.main.cpp index 8e26791a..b7714a3e 100644 --- a/src/scenedit/scen.main.cpp +++ b/src/scenedit/scen.main.cpp @@ -205,7 +205,6 @@ void handle_menu_choice(eMenu item_hit) { current_terrain = scenario.outdoors[cur_out.x][cur_out.y]; overall_mode = MODE_MAIN_SCREEN; change_made = false; - update_item_menu(); set_up_main_screen(); } break; @@ -497,22 +496,6 @@ void handle_menu_choice(eMenu item_hit) { cChoiceDlog(helpDlog).show(); } -void handle_item_menu(int item_hit) { - if(scenario.scen_items[item_hit].variety == eItemType::NO_ITEM) { - giveError("This item has its Variety set to No Item. You can only place items with a Variety set to an actual item type."); - return; - } - overall_mode = MODE_PLACE_ITEM; - set_string("Place the item.","Select item location"); - mode_count = item_hit; -} - -void handle_monst_menu(int item_hit) { - overall_mode = MODE_PLACE_CREATURE; - set_string("Place the monster.","Select monster location"); - mode_count = item_hit; -} - static void handleUpdateWhileScrolling(volatile bool& doneScrolling) { while(!doneScrolling) { sf::sleep(sf::milliseconds(10)); diff --git a/src/scenedit/scen.menu.xib b/src/scenedit/scen.menu.xib index 82920e00..9cb0d530 100644 --- a/src/scenedit/scen.menu.xib +++ b/src/scenedit/scen.menu.xib @@ -788,131 +788,6 @@ YES - - - I1 - - 2147483647 - - - submenuAction: - - I1 - - - - - - I2 - - 2147483647 - - - submenuAction: - - I2 - - YES - - - - - I3 - - 2147483647 - - - submenuAction: - - I3 - - YES - - - - - I4 - - 2147483647 - - - submenuAction: - - I4 - - YES - - - - - I5 - - 2147483647 - - - submenuAction: - - I5 - - YES - - - - - M1 - - 2147483647 - - - submenuAction: - - M1 - - YES - - - - - M2 - - 2147483647 - - - submenuAction: - - M2 - - YES - - - - - M3 - - 2147483647 - - - submenuAction: - - M3 - - YES - - - - - M4 - - 2147483647 - - - submenuAction: - - M4 - - YES - - Help @@ -1098,15 +973,6 @@ - - - - - - - - - @@ -1701,132 +1567,6 @@ - - 856 - - - - - - - - 857 - - - - - - 859 - - - - - - - - 860 - - - - - - 862 - - - - - - - - 863 - - - - - - 865 - - - - - - - - 866 - - - - - - 868 - - - - - - - - 869 - - - - - - 871 - - - - - - - - 872 - - - - - - 874 - - - - - - - - 875 - - - - - - 877 - - - - - - - - 878 - - - - - - 880 - - - - - - - - 881 - - - - 883 @@ -1953,24 +1693,6 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin diff --git a/src/scenedit/scen.menus.h b/src/scenedit/scen.menus.h index 5794f91e..be18da66 100644 --- a/src/scenedit/scen.menus.h +++ b/src/scenedit/scen.menus.h @@ -10,7 +10,6 @@ #define BoE_scen_menus_h void init_menubar(); -void update_item_menu(); void shut_down_menus(short mode); enum class eMenu { @@ -34,8 +33,6 @@ enum class eMenu { OUT_SPECIALS, OUT_TEXT, OUT_SIGNS, }; -void handle_item_menu(int item_hit); -void handle_monst_menu(int item_hit); void handle_menu_choice(eMenu item_hit); #endif diff --git a/src/scenedit/scen.menus.mac.mm b/src/scenedit/scen.menus.mac.mm index 01336784..0b3f1aea 100644 --- a/src/scenedit/scen.menus.mac.mm +++ b/src/scenedit/scen.menus.mac.mm @@ -13,15 +13,12 @@ using MenuHandle = NSMenu*; MenuHandle menu_bar_handle; -MenuHandle item_menu[5], mon_menu[4]; MenuHandle file_menu, edit_menu, app_menu, scen_menu, town_menu, out_menu, help_menu; extern cScenario scenario; @interface MenuHandler : NSObject -(void) menuChoice:(id) sender; --(void) itemMenu:(id) sender; --(void) monstMenu:(id) sender; @end static void setMenuCallback(NSMenuItem* item, id targ, SEL selector, int num) { @@ -46,15 +43,6 @@ void init_menubar() { town_menu = [[menu_bar_handle itemWithTitle: @"Town"] submenu]; out_menu = [[menu_bar_handle itemWithTitle: @"Outdoors"] submenu]; help_menu = [[menu_bar_handle itemWithTitle: @"Help"] submenu]; - item_menu[0] = [[menu_bar_handle itemWithTitle: @"I1"] submenu]; - item_menu[1] = [[menu_bar_handle itemWithTitle: @"I2"] submenu]; - item_menu[2] = [[menu_bar_handle itemWithTitle: @"I3"] submenu]; - item_menu[3] = [[menu_bar_handle itemWithTitle: @"I4"] submenu]; - item_menu[4] = [[menu_bar_handle itemWithTitle: @"I5"] submenu]; - mon_menu[0] = [[menu_bar_handle itemWithTitle: @"M1"] submenu]; - mon_menu[1] = [[menu_bar_handle itemWithTitle: @"M2"] submenu]; - mon_menu[2] = [[menu_bar_handle itemWithTitle: @"M3"] submenu]; - mon_menu[3] = [[menu_bar_handle itemWithTitle: @"M4"] submenu]; static const eMenu file_choices[] = { eMenu::FILE_NEW, eMenu::FILE_OPEN, eMenu::NONE, eMenu::FILE_CLOSE, eMenu::FILE_SAVE, eMenu::FILE_REVERT, @@ -115,15 +103,6 @@ void shut_down_menus(short mode) { [[menu_bar_handle itemWithTitle: @"Scenario"] setEnabled: NO]; [[menu_bar_handle itemWithTitle: @"Town"] setEnabled: NO]; [[menu_bar_handle itemWithTitle: @"Outdoors"] setEnabled: NO]; - [[menu_bar_handle itemWithTitle: @"I1"] setEnabled: NO]; - [[menu_bar_handle itemWithTitle: @"I2"] setEnabled: NO]; - [[menu_bar_handle itemWithTitle: @"I3"] setEnabled: NO]; - [[menu_bar_handle itemWithTitle: @"I4"] setEnabled: NO]; - [[menu_bar_handle itemWithTitle: @"I5"] setEnabled: NO]; - [[menu_bar_handle itemWithTitle: @"M1"] setEnabled: NO]; - [[menu_bar_handle itemWithTitle: @"M2"] setEnabled: NO]; - [[menu_bar_handle itemWithTitle: @"M3"] setEnabled: NO]; - [[menu_bar_handle itemWithTitle: @"M4"] setEnabled: NO]; } if(mode == 4) { [[file_menu itemWithTitle: @"Save"] setEnabled: YES]; @@ -138,30 +117,12 @@ void shut_down_menus(short mode) { for(id item in [out_menu itemArray]) if(![[item title] isEqualToString: @"Advanced:"]) [item setEnabled: YES]; - [[menu_bar_handle itemWithTitle: @"I1"] setEnabled: YES]; - [[menu_bar_handle itemWithTitle: @"I2"] setEnabled: YES]; - [[menu_bar_handle itemWithTitle: @"I3"] setEnabled: YES]; - [[menu_bar_handle itemWithTitle: @"I4"] setEnabled: YES]; - [[menu_bar_handle itemWithTitle: @"I5"] setEnabled: YES]; - [[menu_bar_handle itemWithTitle: @"M1"] setEnabled: YES]; - [[menu_bar_handle itemWithTitle: @"M2"] setEnabled: YES]; - [[menu_bar_handle itemWithTitle: @"M3"] setEnabled: YES]; - [[menu_bar_handle itemWithTitle: @"M4"] setEnabled: YES]; } if((mode == 1) || (mode == 3)) { MenuHandle town_menu = [[menu_bar_handle itemWithTitle: @"Town"] submenu]; for(id item in [town_menu itemArray]) if([[item title] length] > 0 && [[item title] characterAtIndex: 0] != ' ') [item setEnabled: NO]; - [[menu_bar_handle itemWithTitle: @"I1"] setEnabled: NO]; - [[menu_bar_handle itemWithTitle: @"I2"] setEnabled: NO]; - [[menu_bar_handle itemWithTitle: @"I3"] setEnabled: NO]; - [[menu_bar_handle itemWithTitle: @"I4"] setEnabled: NO]; - [[menu_bar_handle itemWithTitle: @"I5"] setEnabled: NO]; - [[menu_bar_handle itemWithTitle: @"M1"] setEnabled: NO]; - [[menu_bar_handle itemWithTitle: @"M2"] setEnabled: NO]; - [[menu_bar_handle itemWithTitle: @"M3"] setEnabled: NO]; - [[menu_bar_handle itemWithTitle: @"M4"] setEnabled: NO]; } if((mode == 2) || (mode == 3)) { MenuHandle out_menu = [[menu_bar_handle itemWithTitle: @"Outdoors"] submenu]; @@ -171,40 +132,8 @@ void shut_down_menus(short mode) { } } -void update_item_menu() { - MenuHandler* targ = [[file_menu itemAtIndex: 0] target]; - short i,j; - - for(j = 0; j < 5; j++) { - [item_menu[j] removeAllItems]; - for(i = 0; i < 80; i++) { - NSString* title = [NSString stringWithCString: scenario.scen_items[i + j * 80].full_name.c_str() encoding: NSASCIIStringEncoding]; - NSMenuItem* newItem = [item_menu[j] addItemWithTitle: title action: @selector(itemMenu:) keyEquivalent:@""]; - [newItem setTarget: targ]; - } - } - for(j = 0; j < 4; j++) { - [mon_menu[j] removeAllItems]; - for(i = 0; i < 64; i++) { - NSString* title = [NSString stringWithCString: scenario.scen_monsters[i + j * 64].m_name.c_str() encoding: NSASCIIStringEncoding]; - NSMenuItem* newItem = [mon_menu[j] addItemWithTitle: title action: @selector(monstMenu:) keyEquivalent: @""]; - [newItem setTarget: targ]; - } - } - -} - @implementation MenuHandler -(void) menuChoice:(id) sender { handle_menu_choice(eMenu([[sender representedObject] intValue])); } - -// TODO: Monster and item menus --(void) itemMenu:(id) sender { - (void) sender; // Suppress "unused parameter" warning -} - --(void) monstMenu:(id) sender { - (void) sender; // Suppress "unused parameter" warning -} @end diff --git a/src/scenedit/scen.menus.win.cpp b/src/scenedit/scen.menus.win.cpp index 7f357eb2..dba8d03d 100644 --- a/src/scenedit/scen.menus.win.cpp +++ b/src/scenedit/scen.menus.win.cpp @@ -19,9 +19,7 @@ enum { SCEN_MENU_POS = 2, TOWN_MENU_POS = 3, OUT_MENU_POS = 4, - ITEMS_MENU_POS = 6, - MONST_MENU_POS = 11, - HELP_MENU_POS = 15, + HELP_MENU_POS = 6, }; extern sf::RenderWindow mainPtr; @@ -130,29 +128,6 @@ void init_menubar() { accel.build(); } -void update_item_menu() { - if(menuHandle == NULL) return; - for(int j = 0; j < 5; j++) { - HMENU item_menu = GetSubMenu(menuHandle, ITEMS_MENU_POS + j); - while(GetMenuItemCount(item_menu)) RemoveMenu(item_menu, 0, MF_BYPOSITION); - for(int i = 0; i < 80; i++) { - UINT flags = MF_STRING | MF_ENABLED; - if(i % 20 == 0) flags |= MF_MENUBARBREAK; - AppendMenuA(item_menu, flags, 10000 + i + j * 80, scenario.scen_items[i + j * 80].full_name.c_str()); - } - } - for(int j = 0; j < 4; j++) { - HMENU mon_menu = GetSubMenu(menuHandle, MONST_MENU_POS + j); - while(GetMenuItemCount(mon_menu)) RemoveMenu(mon_menu, 0, MF_BYPOSITION); - for(int i = 0; i < 64; i++) { - UINT flags = MF_STRING | MF_ENABLED; - if(i % 32 == 0) flags |= MF_MENUBARBREAK; - AppendMenuA(mon_menu, flags, 20000 + i + j * 64, scenario.scen_monsters[i + j * 64].m_name.c_str()); - } - } - DrawMenuBar(mainPtr.getSystemHandle()); -} - void shut_down_menus(short mode) { if(menuHandle == NULL) return; HMENU file_menu = GetSubMenu(menuHandle, FILE_MENU_POS); @@ -161,10 +136,6 @@ void shut_down_menus(short mode) { EnableMenuItem(menuHandle, SCEN_MENU_POS, MF_GRAYED | MF_BYPOSITION); EnableMenuItem(menuHandle, TOWN_MENU_POS, MF_GRAYED | MF_BYPOSITION); EnableMenuItem(menuHandle, OUT_MENU_POS, MF_GRAYED | MF_BYPOSITION); - for(int i = 0; i < 5; i++) - EnableMenuItem(menuHandle, ITEMS_MENU_POS + i, MF_GRAYED | MF_BYPOSITION); - for(int i = 0; i < 4; i++) - EnableMenuItem(menuHandle, MONST_MENU_POS + i, MF_GRAYED | MF_BYPOSITION); } std::shared_ptr buf(new char[256]); MENUITEMINFOA info; @@ -176,10 +147,6 @@ void shut_down_menus(short mode) { EnableMenuItem(menuHandle, SCEN_MENU_POS, MF_ENABLED | MF_BYPOSITION); EnableMenuItem(menuHandle, TOWN_MENU_POS, MF_ENABLED | MF_BYPOSITION); EnableMenuItem(menuHandle, OUT_MENU_POS, MF_ENABLED | MF_BYPOSITION); - for(int i = 0; i < 5; i++) - EnableMenuItem(menuHandle, ITEMS_MENU_POS + i, MF_ENABLED | MF_BYPOSITION); - for(int i = 0; i < 4; i++) - EnableMenuItem(menuHandle, MONST_MENU_POS + i, MF_ENABLED | MF_BYPOSITION); HMENU town_menu = GetSubMenu(menuHandle, TOWN_MENU_POS); for(int i = 0; i < GetMenuItemCount(town_menu); i++) { @@ -199,11 +166,6 @@ void shut_down_menus(short mode) { } } if((mode == 1) || (mode == 3)) { - for(int i = 0; i < 5; i++) - EnableMenuItem(menuHandle, ITEMS_MENU_POS + i, MF_GRAYED | MF_BYPOSITION); - for(int i = 0; i < 4; i++) - EnableMenuItem(menuHandle, MONST_MENU_POS + i, MF_GRAYED | MF_BYPOSITION); - HMENU town_menu = GetSubMenu(menuHandle, TOWN_MENU_POS); for(int i = 0; i < GetMenuItemCount(town_menu); i++) { info.cch = 256;