diff --git a/bin/data/openttdd.grf b/bin/data/openttdd.grf index 2d4de97e3f..71a95bb2c6 100644 Binary files a/bin/data/openttdd.grf and b/bin/data/openttdd.grf differ diff --git a/bin/data/openttdw.grf b/bin/data/openttdw.grf index c8852b4d93..9c327d2c81 100644 Binary files a/bin/data/openttdw.grf and b/bin/data/openttdw.grf differ diff --git a/src/table/files.h b/src/table/files.h index 8381672cad..b4ef2e4b9f 100644 --- a/src/table/files.h +++ b/src/table/files.h @@ -35,7 +35,7 @@ static FileList files_dos = { { "TRGT.GRF", {0xfc, 0xde, 0x1d, 0x7e, 0x8a, 0x74, 0x19, 0x7d, 0x72, 0xa6, 0x26, 0x95, 0x88, 0x4b, 0x90, 0x9e} } }, { "SAMPLE.CAT", {0x42, 0x2e, 0xa3, 0xdd, 0x07, 0x4d, 0x28, 0x59, 0xbb, 0x51, 0x63, 0x9a, 0x6e, 0x0e, 0x85, 0xda} }, - { "OPENTTDD.GRF", {0xb2, 0xbd, 0xd2, 0xa4, 0x1b, 0xfa, 0x2c, 0x60, 0x4f, 0xd5, 0x5e, 0x4c, 0xb5, 0xba, 0x37, 0x73} } + { "OPENTTDD.GRF", {0xb6, 0xed, 0x9a, 0x20, 0x89, 0xad, 0x6e, 0xa1, 0x55, 0x10, 0xad, 0x00, 0x53, 0xa3, 0xd5, 0xbc} } }; @@ -49,5 +49,5 @@ static FileList files_win = { { "TRGTR.GRF", {0xde, 0x53, 0x65, 0x05, 0x17, 0xfe, 0x66, 0x1c, 0xea, 0xa3, 0x13, 0x8c, 0x6e, 0xdb, 0x0e, 0xb8} } }, { "SAMPLE.CAT", {0x92, 0x12, 0xe8, 0x1e, 0x72, 0xba, 0xdd, 0x4b, 0xbe, 0x1e, 0xae, 0xae, 0x66, 0x45, 0x8e, 0x10} }, - { "OPENTTDW.GRF", {0x3b, 0x1a, 0x0d, 0x8c, 0x2d, 0x01, 0x0e, 0xee, 0x47, 0x7f, 0x5d, 0x70, 0x8f, 0xb2, 0xe4, 0xfb} } + { "OPENTTDW.GRF", {0x41, 0x1e, 0xb6, 0xb2, 0xd2, 0xc4, 0x30, 0x6e, 0x7b, 0xc7, 0xdc, 0x39, 0xd4, 0x40, 0x46, 0xfb} } }; diff --git a/src/table/sprites.h b/src/table/sprites.h index 115ed663d6..c357ba7eef 100644 --- a/src/table/sprites.h +++ b/src/table/sprites.h @@ -49,7 +49,7 @@ enum Sprites { /* Extra graphic spritenumbers */ SPR_OPENTTD_BASE = 4896, - OPENTTD_SPRITE_COUNT = 144, + OPENTTD_SPRITE_COUNT = 145, /* Halftile-selection sprites */ SPR_HALFTILE_SELECTION_FLAT = SPR_OPENTTD_BASE, @@ -122,6 +122,8 @@ enum Sprites { SPR_GROUP_REPLACE_OFF_SHIP = SPR_OPENTTD_BASE + 132, SPR_GROUP_REPLACE_OFF_AIRCRAFT = SPR_OPENTTD_BASE + 133, + SPR_SWITCH_TOOLBAR = SPR_OPENTTD_BASE + 144, + SPR_SIGNALS_BASE = SPR_OPENTTD_BASE + OPENTTD_SPRITE_COUNT, PRESIGNAL_SPRITE_COUNT = 48, PRESIGNAL_AND_SEMAPHORE_SPRITE_COUNT = 112, diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index 1285ea34ab..f980c69309 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -47,10 +47,19 @@ static void PopupMainToolbMenu(Window *parent, uint16 parent_button, StringID base_string, byte item_count, byte disabled_mask = 0, int sel_index = 0, int checked_items = 0); static void PopupMainPlayerToolbMenu(Window *parent, int main_button, int gray); +static void SplitToolbar(Window *w); RailType _last_built_railtype; RoadType _last_built_roadtype; +enum ToolbarMode { + TB_NORMAL, + TB_UPPER, + TB_LOWER +}; + +static ToolbarMode _toolbar_mode; + static void SelectSignTool() { if (_cursor.sprite == SPR_CURSOR_SIGN) { @@ -282,7 +291,7 @@ static void MenuClickCompany(int index) static void ToolbarGraphsClick(Window *w) { - PopupMainToolbMenu(w, 10, STR_0154_OPERATING_PROFIT_GRAPH, 6); + PopupMainToolbMenu(w, 10, STR_0154_OPERATING_PROFIT_GRAPH, (_toolbar_mode == TB_NORMAL) ? 6 : 8); } static void MenuClickGraphs(int index) @@ -294,6 +303,9 @@ static void MenuClickGraphs(int index) case 3: ShowPerformanceHistoryGraph(); break; case 4: ShowCompanyValueGraph(); break; case 5: ShowCargoPaymentRates(); break; + /* functions for combined graphs/league button */ + case 6: ShowCompanyLeagueTable(); break; + case 7: ShowPerformanceRatingDetail(); break; } } @@ -533,6 +545,22 @@ static void MenuClickHelp(int index) } } +/* --- Switch toolbar button --- */ + +static void ToolbarSwitchClick(Window *w) +{ + if (_toolbar_mode != TB_LOWER) { + _toolbar_mode = TB_LOWER; + } else { + _toolbar_mode = TB_UPPER; + } + + SplitToolbar(w); + w->HandleButtonClick(27); + SetWindowDirty(w); + SndPlayFx(SND_15_BEEP); +} + /* --- Scenario editor specific handlers. */ static void ToolbarScenDateBackward(Window *w) @@ -631,6 +659,90 @@ static void ToolbarBtn_NULL(Window *w) { } +/* --- Resizing the toolbar */ + +static void ResizeToolbar(Window *w) +{ + /* There are 27 buttons plus some spacings if the space allows it */ + uint button_width; + uint spacing; + if (w->width >= 27 * 22) { + button_width = 22; + spacing = w->width - (27 * button_width); + } else { + button_width = w->width / 27; + spacing = 0; + } + uint extra_spacing_at[] = { 4, 8, 13, 17, 19, 24, 0 }; + + for (uint i = 0, x = 0, j = 0; i < 27; i++) { + if (extra_spacing_at[j] == i) { + j++; + uint add = spacing / (lengthof(extra_spacing_at) - j); + spacing -= add; + x += add; + } + + w->widget[i].type = WWT_IMGBTN; + w->widget[i].left = x; + x += (spacing != 0) ? button_width : (w->width - x) / (27 - i); + w->widget[i].right = x - 1; + } + + w->widget[27].type = WWT_EMPTY; + _toolbar_mode = TB_NORMAL; +} + +/* --- Split the toolbar */ + +static void SplitToolbar(Window *w) +{ + static const byte arrange14[] = { + 0, 1, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 27, + 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 24, 25, 26, 27, + }; + static const byte arrange15[] = { + 0, 1, 4, 13, 14, 15, 16, 19, 20, 21, 22, 23, 17, 18, 27, + 0, 2, 4, 3, 5, 6, 7, 8, 9, 10, 12, 24, 25, 26, 27, + }; + static const byte arrange16[] = { + 0, 1, 2, 4, 13, 14, 15, 16, 19, 20, 21, 22, 23, 17, 18, 27, + 0, 1, 3, 5, 6, 7, 8, 9, 10, 12, 24, 25, 26, 17, 18, 27, + }; + static const byte arrange17[] = { + 0, 1, 2, 4, 6, 13, 14, 15, 16, 19, 20, 21, 22, 23, 17, 18, 27, + 0, 1, 3, 4, 6, 5, 7, 8, 9, 10, 12, 24, 25, 26, 17, 18, 27, + }; + static const byte arrange18[] = { + 0, 1, 2, 4, 5, 6, 7, 8, 9, 12, 19, 20, 21, 22, 23, 17, 18, 27, + 0, 1, 3, 4, 5, 6, 7, 10, 13, 14, 15, 16, 24, 25, 26, 17, 18, 27, + }; + static const byte arrange19[] = { + 0, 1, 2, 4, 5, 6, 13, 14, 15, 16, 19, 20, 21, 22, 23, 24, 17, 18, 27, + 0, 1, 3, 4, 7, 8, 9, 10, 12, 25, 19, 20, 21, 22, 23, 26, 17, 18, 27, + }; + + static const byte *arrangements[] = { arrange14, arrange15, arrange16, arrange17, arrange18, arrange19 }; + + static const uint icon_size = 22; + uint max_icons = max(14U, (w->width + icon_size / 2) / icon_size); + + assert(max_icons >= 14 && max_icons <= 19); + + /* first hide all icons */ + for (uint i = 0; i < 27; i++) { + w->widget[i].type = WWT_EMPTY; + } + + /* now activate them all on their proper positions */ + for (uint i = 0, x = 0, n = max_icons - 14; i < max_icons; i++) { + uint icon = arrangements[n][i + ((_toolbar_mode == TB_LOWER) ? max_icons : 0)]; + w->widget[icon].type = WWT_IMGBTN; + w->widget[icon].left = x; + x += (w->width - x) / (max_icons - i); + w->widget[icon].right = x - 1; + } +} /* --- Toolbar handling for the 'normal' case */ @@ -664,6 +776,7 @@ static ToolbarButtonProc * const _toolbar_button_procs[] = { ToolbarMusicClick, ToolbarNewspaperClick, ToolbarHelpClick, + ToolbarSwitchClick, }; struct MainToolbarWindow : Window { @@ -774,29 +887,10 @@ struct MainToolbarWindow : Window { virtual void OnResize(Point new_size, Point delta) { - /* There are 27 buttons plus some spacings if the space allows it */ - uint button_width; - uint spacing; - if (this->width >= 27 * 22) { - button_width = 22; - spacing = this->width - (27 * button_width); + if (this->width <= 19 * 22) { + SplitToolbar(this); } else { - button_width = this->width / 27; - spacing = 0; - } - uint extra_spacing_at[] = { 4, 8, 13, 17, 19, 24, 0 }; - - for (uint i = 0, x = 0, j = 0; i < 27; i++) { - if (extra_spacing_at[j] == i) { - j++; - uint add = spacing / (lengthof(extra_spacing_at) - j); - spacing -= add; - x += add; - } - - this->widget[i].left = x; - x += (spacing != 0) ? button_width : (this->width - x) / (27 - i); - this->widget[i].right = x - 1; + ResizeToolbar(this); } } @@ -850,6 +944,7 @@ static const Widget _toolb_normal_widgets[] = { { WWT_IMGBTN, RESIZE_NONE, 14, 0, 0, 0, 21, SPR_IMG_MUSIC, STR_01D4_SHOW_SOUND_MUSIC_WINDOW}, { WWT_IMGBTN, RESIZE_NONE, 14, 0, 0, 0, 21, SPR_IMG_MESSAGES, STR_0203_SHOW_LAST_MESSAGE_NEWS}, { WWT_IMGBTN, RESIZE_NONE, 14, 0, 0, 0, 21, SPR_IMG_QUERY, STR_0186_LAND_BLOCK_INFORMATION}, +{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 0, 0, 21, SPR_SWITCH_TOOLBAR, STR_EMPTY}, // switch toolbar button. only active when toolbar has been split { WIDGETS_END}, };