--- a/lang/english.txt Mon Aug 16 18:46:54 2004 +0000
+++ b/lang/english.txt Mon Aug 16 21:02:06 2004 +0000
@@ -1000,6 +1000,10 @@
STR_CONFIG_PATCHES_STARTING_DATE :{LTBLUE}Starting date: {ORANGE}{STRING}
STR_CONFIG_PATCHES_SMOOTH_ECONOMY :{LTBLUE}Enable smooth economy (more, smaller changes)
STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY :{LTBLUE}When dragging place signals every: {ORANGE}{STRING} tile(s)
+STR_CONFIG_PATCHES_TOOLBAR_POS :{LTBLUE}Position of maintoolbar: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_TOOLBAR_POS_LEFT :Left
+STR_CONFIG_PATCHES_TOOLBAR_POS_CENTER :Center
+STR_CONFIG_PATCHES_TOOLBAR_POS_RIGHT :Right
STR_CONFIG_PATCHES_GUI :{BLACK}Interface
STR_CONFIG_PATCHES_CONSTRUCTION :{BLACK}Construction
--- a/main_gui.c Mon Aug 16 18:46:54 2004 +0000
+++ b/main_gui.c Mon Aug 16 21:02:06 2004 +0000
@@ -2207,6 +2207,8 @@
w = AllocateWindowDesc(&_toolb_normal_desc);
w->disabled_state = 1 << 17;
w->flags4 &= ~WF_WHITE_BORDER_MASK;
+
+ PositionMainToolbar(w); // already WC_MAIN_TOOLBAR passed (&_toolb_normal_desc)
_main_status_desc.top = height - 12;
w = AllocateWindowDesc(&_main_status_desc);
@@ -2222,6 +2224,8 @@
w = AllocateWindowDesc(&_toolb_scen_desc);
w->disabled_state = 1 << 9;
w->flags4 &= ~WF_WHITE_BORDER_MASK;
+
+ PositionMainToolbar(w); // already WC_MAIN_TOOLBAR passed (&_toolb_scen_desc)
break;
default:
NOT_REACHED();
--- a/settings.c Mon Aug 16 18:46:54 2004 +0000
+++ b/settings.c Mon Aug 16 21:02:06 2004 +0000
@@ -826,6 +826,8 @@
{"nonuniform_stations", SDT_BOOL, (void*)false, (void*)offsetof(Patches, nonuniform_stations)},
{"always_small_airport", SDT_BOOL, (void*)false, (void*)offsetof(Patches, always_small_airport)},
{"realistic_acceleration", SDT_BOOL, (void*)false, (void*)offsetof(Patches, realistic_acceleration)},
+
+ {"toolbar_pos", SDT_UINT8, (void*)0, (void*)offsetof(Patches, toolbar_pos)},
{"max_trains", SDT_UINT8, (void*)80,(void*)offsetof(Patches, max_trains)},
{"max_roadveh", SDT_UINT8, (void*)80,(void*)offsetof(Patches, max_roadveh)},
--- a/settings_gui.c Mon Aug 16 18:46:54 2004 +0000
+++ b/settings_gui.c Mon Aug 16 21:02:06 2004 +0000
@@ -661,13 +661,28 @@
ShowInfoF("ShowHighscoreTable(%d) not implemented", tbl);
}
+// virtual PositionMainToolbar function, calls the right one.
+int32 v_PositionMainToolbar(int32 p1)
+{
+ if (_game_mode != GM_MENU)
+ PositionMainToolbar(NULL);
+
+ return 0;
+}
+
+typedef int32 PatchButtonClick(int32);
+static PatchButtonClick * const _patch_button_proc[] = {
+ &v_PositionMainToolbar,
+};
+
typedef struct PatchEntry {
- byte type; // type of selector
- byte flags; // selector flags
- StringID str; // string with descriptive text
- void *variable; // pointer to the variable
- int32 min,max; // range for spinbox setting
- uint32 step; // step for spinbox
+ byte type; // type of selector
+ byte flags; // selector flags
+ StringID str; // string with descriptive text
+ void *variable; // pointer to the variable
+ int32 min,max; // range for spinbox setting
+ uint32 step; // step for spinbox
+ PatchButtonClick *click_proc; // callback procedure
} PatchEntry;
enum {
@@ -691,6 +706,7 @@
{PE_UINT8, 0, STR_CONFIG_PATCHES_ERRMSG_DURATION, &_patches.errmsg_duration, 0, 20, 1},
+ {PE_UINT8, PF_MULTISTRING, STR_CONFIG_PATCHES_TOOLBAR_POS, &_patches.toolbar_pos, 0, 2, 1, &v_PositionMainToolbar},
};
static const PatchEntry _patches_construction[] = {
@@ -927,7 +943,7 @@
x = e->click.pt.x - 5;
if (x < 0) return;
- if (x < 21) {
+ if (x < 21) { // clicked on the icon on the left side. Either scroller or bool on/off
int32 val = ReadPE(pe), oval = val;
switch(pe->type) {
@@ -972,9 +988,12 @@
if (val != oval) {
WritePE(pe, val);
SetWindowDirty(w);
+
+ if (pe->click_proc != NULL) // call callback function
+ pe->click_proc(val);
}
} else {
- if (pe->type != PE_BOOL) {
+ if (pe->type != PE_BOOL && !(pe->flags & PF_MULTISTRING)) { // do not open editbox
WP(w,def_d).data_3 = btn;
SET_DPARAM32(0, ReadPE(pe));
ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_CONFIG_PATCHES_QUERY_CAPT, 10, 100, WC_GAME_OPTIONS, 0);
@@ -999,8 +1018,12 @@
case WE_ON_EDIT_TEXT: {
if (*e->edittext.str) {
const PatchPage *page = &_patches_page[WP(w,def_d).data_1];
- WritePE(&page->entries[WP(w,def_d).data_3], atoi(e->edittext.str));
+ const PatchEntry *pe = &page->entries[WP(w,def_d).data_3];
+ WritePE(pe, atoi(e->edittext.str));
SetWindowDirty(w);
+
+ if (pe->click_proc != NULL) // call callback function
+ pe->click_proc(*(int32*)pe->variable);
}
break;
}
--- a/variables.h Mon Aug 16 18:46:54 2004 +0000
+++ b/variables.h Mon Aug 16 21:02:06 2004 +0000
@@ -109,6 +109,8 @@
bool nonuniform_stations;// allow nonuniform train stations
bool always_small_airport; // always allow small airports
bool realistic_acceleration; // realistic acceleration for trains
+
+ uint8 toolbar_pos; // position of toolbars, 0=left, 1=center, 2=right
byte max_trains; //max trains in game per player (these are 8bit because the unitnumber field can't hold more)
byte max_roadveh; //max trucks in game per player
--- a/window.c Mon Aug 16 18:46:54 2004 +0000
+++ b/window.c Mon Aug 16 21:02:06 2004 +0000
@@ -531,6 +531,16 @@
if (pt.x > _screen.width + 10 - desc->width)
pt.x = (_screen.width + 10 - desc->width) - 20;
pt.y = w->top + 10;
+ // open Build Toolbars and Terraforming Toolbar aligned
+ } else if (desc->cls == WC_BUILD_TOOLBAR || desc->cls == WC_SCEN_LAND_GEN) {
+ /* Override the position if a toolbar is opened according to the place of the maintoolbar
+ * The main toolbar (WC_MAIN_TOOLBAR) is 640px in width */
+ switch (_patches.toolbar_pos) {
+ case 1: pt.x = ((_screen.width + 640) >> 1) - desc->width; break;
+ case 2: pt.x = _screen.width - desc->width; break;
+ default: pt.x = 640 - desc->width;
+ }
+ pt.y = desc->top;
} else {
pt.x = desc->left;
pt.y = desc->top;
@@ -1013,7 +1023,7 @@
}
if (click == 1) {
- DEBUG(misc, 1) ("cursor: 0x%X (%d)", _cursor.sprite, _cursor.sprite);
+ //DEBUG(misc, 1) ("cursor: 0x%X (%d)", _cursor.sprite, _cursor.sprite);
if (_thd.place_mode != 0 &&
// query button and place sign button work in pause mode
!(_cursor.sprite == 0x2CF || _cursor.sprite == 0x2D2) &&
@@ -1164,6 +1174,22 @@
}
}
+int PositionMainToolbar(Window *w)
+{
+ //DEBUG(misc, 1) ("Repositioning Main Toolbar...");
+
+ if (w == NULL || w->window_class != WC_MAIN_TOOLBAR)
+ w = FindWindowById(WC_MAIN_TOOLBAR, 0);
+
+ switch (_patches.toolbar_pos) {
+ case 1: w->left = (_screen.width - w->width) >> 1; break;
+ case 2: w->left = _screen.width - w->width; break;
+ default: w->left = 0;
+ }
+ SetDirtyBlocks(0, 0, _screen.width, w->height); // invalidate the whole top part
+ return w->left;
+}
+
void RelocateAllWindows(int neww, int newh)
{
Window *w;
@@ -1182,7 +1208,7 @@
if (w->window_class == WC_MAIN_TOOLBAR) {
top = w->top;
- left = (neww - w->width) >> 1;
+ left = PositionMainToolbar(w); // changes toolbar orientation
} else if (w->window_class == WC_SELECT_GAME || w->window_class == WC_GAME_OPTIONS || w->window_class == WC_NETWORK_WINDOW){
top = (newh - w->height) >> 1;
left = (neww - w->width) >> 1;
@@ -1208,4 +1234,3 @@
w->top = top;
}
}
-
--- a/window.h Mon Aug 16 18:46:54 2004 +0000
+++ b/window.h Mon Aug 16 21:02:06 2004 +0000
@@ -408,6 +408,7 @@
void UnclickWindowButtons(Window *w);
void UnclickSomeWindowButtons(Window *w, uint32 mask);
void RelocateAllWindows(int neww, int newh);
+int32 PositionMainToolbar(Window *w);
/* widget.c */
int GetWidgetFromPos(Window *w, int x, int y);