From f186b640f6def6fafd38f6511a630b34de52906b Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Mon, 26 Feb 2024 21:41:26 +0000 Subject: [PATCH] Plans: Add initial scenario editor support See: #655 --- src/plans_gui.cpp | 3 ++- src/toolbar_gui.cpp | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plans_gui.cpp b/src/plans_gui.cpp index 6691d6b177..d45a16f32f 100644 --- a/src/plans_gui.cpp +++ b/src/plans_gui.cpp @@ -12,6 +12,7 @@ #include "plans_base.h" #include "command_func.h" #include "company_func.h" +#include "company_base.h" #include "company_gui.h" #include "settings_gui.h" #include "window_gui.h" @@ -287,7 +288,7 @@ struct PlansWindow : Window { if (i == this->selected) GfxFillRect(r.left + 1, y, r.right, y + this->resize.step_height, PC_DARK_GREY); if (list[i].is_plan) { - DrawCompanyIcon(p->owner, icon_left, y + (this->resize.step_height - this->company_icon_spr_dim.height) / 2); + if (Company::IsValidID(p->owner)) DrawCompanyIcon(p->owner, icon_left, y + (this->resize.step_height - this->company_icon_spr_dim.height) / 2); DrawBoolButton(btn_left, y + (this->resize.step_height - SETTING_BUTTON_HEIGHT) / 2, p->visible, true); uint dparam_offset = 0; StringID str = p->HasName() ? STR_PLANS_LIST_ITEM_NAMED_PLAN : STR_PLANS_LIST_ITEM_PLAN; diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index 9a4b8486d6..edb716a3fe 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -444,6 +444,7 @@ static CallBackFunction ToolbarScenMapTownDir(Window *w) list.push_back(std::make_unique(STR_MAP_MENU_MAP_OF_WORLD, MME_SHOW_SMALLMAP, false)); list.push_back(std::make_unique(STR_MAP_MENU_EXTRA_VIEWPORT, MME_SHOW_EXTRAVIEWPORTS, false)); list.push_back(std::make_unique(STR_MAP_MENU_SIGN_LIST, MME_SHOW_SIGNLISTS, false)); + list.push_back(std::make_unique(STR_MAP_MENU_PLAN_LIST, MME_SHOW_PLANS, false)); list.push_back(std::make_unique(STR_TOWN_MENU_TOWN_DIRECTORY, MME_SHOW_TOWNDIRECTORY, false)); list.push_back(std::make_unique(STR_INDUSTRY_MENU_INDUSTRY_DIRECTORY, MME_SHOW_INDUSTRYDIRECTORY, false)); PopupMainToolbarMenu(w, WID_TE_SMALL_MAP, std::move(list), 0); @@ -2479,6 +2480,7 @@ enum MainToolbarEditorHotkeys { MTEHK_MUSIC, MTEHK_LANDINFO, MTEHK_PICKER, + MTEHK_PLAN_LIST, MTEHK_SMALL_SCREENSHOT, MTEHK_ZOOMEDIN_SCREENSHOT, MTEHK_DEFAULTZOOM_SCREENSHOT, @@ -2598,6 +2600,7 @@ struct ScenarioEditorToolbarWindow : Window { case MTEHK_MUSIC: ShowMusicWindow(); break; case MTEHK_LANDINFO: cbf = PlaceLandBlockInfo(); break; case MTEHK_PICKER: cbf = PlacePickerTool(); break; + case MTEHK_PLAN_LIST: ShowPlansWindow(); break; case MTEHK_SMALL_SCREENSHOT: MakeScreenshotWithConfirm(SC_VIEWPORT); break; case MTEHK_ZOOMEDIN_SCREENSHOT: MakeScreenshotWithConfirm(SC_ZOOMEDIN); break; case MTEHK_DEFAULTZOOM_SCREENSHOT: MakeScreenshotWithConfirm(SC_DEFAULTZOOM); break; @@ -2708,6 +2711,7 @@ static Hotkey scenedit_maintoolbar_hotkeys[] = { Hotkey(WKC_F11, "music", MTEHK_MUSIC), Hotkey(WKC_F12, "land_info", MTEHK_LANDINFO), Hotkey((uint16_t)0, "picker_tool", MTEHK_PICKER), + Hotkey('P', "plan_list", MTEHK_PLAN_LIST), Hotkey(WKC_CTRL | 'S', "small_screenshot", MTEHK_SMALL_SCREENSHOT), Hotkey(WKC_CTRL | 'P', "zoomedin_screenshot", MTEHK_ZOOMEDIN_SCREENSHOT), Hotkey(WKC_CTRL | 'D', "defaultzoom_screenshot", MTEHK_DEFAULTZOOM_SCREENSHOT),