src/signs_gui.cpp
author rubidium
Tue, 06 May 2008 15:11:33 +0000
changeset 9111 48ce04029fe4
parent 8969 6d1c74e0e2cd
child 9115 47ae980bace3
permissions -rw-r--r--
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
9111
48ce04029fe4 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents: 8969
diff changeset
     3
/** @file signs_gui.cpp The GUI for signs. */
6420
456c275f3313 (svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents: 6247
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "stdafx.h"
1891
862800791170 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1575
diff changeset
     6
#include "openttd.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     7
#include "gui.h"
8107
bb7deea89175 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8106
diff changeset
     8
#include "textbuf_gui.h"
bb7deea89175 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8106
diff changeset
     9
#include "window_gui.h"
8254
1496654ca5e7 (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8224
diff changeset
    10
#include "player_gui.h"
8790
4a7a796b3976 (svn r12501) -Codechange: split signs.h.
rubidium
parents: 8749
diff changeset
    11
#include "signs_base.h"
4a7a796b3976 (svn r12501) -Codechange: split signs.h.
rubidium
parents: 8749
diff changeset
    12
#include "signs_func.h"
1575
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    13
#include "debug.h"
2159
f6284cf5fab0 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 2135
diff changeset
    14
#include "variables.h"
8116
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents: 8114
diff changeset
    15
#include "command_func.h"
8114
dd6d21dc99c1 (svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents: 8107
diff changeset
    16
#include "strings_func.h"
8130
d2eb7d04f6e1 (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8121
diff changeset
    17
#include "core/alloc_func.hpp"
8131
160939e24ed3 (svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents: 8130
diff changeset
    18
#include "window_func.h"
8139
4e91c448c409 (svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium
parents: 8131
diff changeset
    19
#include "map_func.h"
8224
c5a64d87cc54 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8139
diff changeset
    20
#include "gfx_func.h"
c5a64d87cc54 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8139
diff changeset
    21
#include "viewport_func.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    22
8264
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8258
diff changeset
    23
#include "table/strings.h"
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8258
diff changeset
    24
#include "table/sprites.h"
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8258
diff changeset
    25
4353
1523114f43f0 (svn r6054) Change the sign sorter in a similar way as the other sorters: Remember a list of pointers to signs instead of a list of SignIDs - This removes a layer of indirection
tron
parents: 4349
diff changeset
    26
static const Sign **_sign_sort;
1523114f43f0 (svn r6054) Change the sign sorter in a similar way as the other sorters: Remember a list of pointers to signs instead of a list of SignIDs - This removes a layer of indirection
tron
parents: 4349
diff changeset
    27
static uint _num_sign_sort;
1575
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    28
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    29
static char _bufcache[64];
4353
1523114f43f0 (svn r6054) Change the sign sorter in a similar way as the other sorters: Remember a list of pointers to signs instead of a list of SignIDs - This removes a layer of indirection
tron
parents: 4349
diff changeset
    30
static const Sign *_last_sign;
1575
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    31
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    32
static int CDECL SignNameSorter(const void *a, const void *b)
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    33
{
4353
1523114f43f0 (svn r6054) Change the sign sorter in a similar way as the other sorters: Remember a list of pointers to signs instead of a list of SignIDs - This removes a layer of indirection
tron
parents: 4349
diff changeset
    34
	const Sign *sign0 = *(const Sign**)a;
1523114f43f0 (svn r6054) Change the sign sorter in a similar way as the other sorters: Remember a list of pointers to signs instead of a list of SignIDs - This removes a layer of indirection
tron
parents: 4349
diff changeset
    35
	const Sign *sign1 = *(const Sign**)b;
1575
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    36
	char buf1[64];
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    37
8258
9fa31acb07bc (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents: 8254
diff changeset
    38
	SetDParam(0, sign0->index);
9fa31acb07bc (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents: 8254
diff changeset
    39
	GetString(buf1, STR_SIGN_NAME, lastof(buf1));
1575
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    40
4353
1523114f43f0 (svn r6054) Change the sign sorter in a similar way as the other sorters: Remember a list of pointers to signs instead of a list of SignIDs - This removes a layer of indirection
tron
parents: 4349
diff changeset
    41
	if (sign1 != _last_sign) {
1523114f43f0 (svn r6054) Change the sign sorter in a similar way as the other sorters: Remember a list of pointers to signs instead of a list of SignIDs - This removes a layer of indirection
tron
parents: 4349
diff changeset
    42
		_last_sign = sign1;
8258
9fa31acb07bc (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents: 8254
diff changeset
    43
		SetDParam(0, sign1->index);
9fa31acb07bc (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents: 8254
diff changeset
    44
		GetString(_bufcache, STR_SIGN_NAME, lastof(_bufcache));
1575
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    45
	}
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    46
3801
4307270e7100 (svn r4809) Codechange : Merged two loops in only one.
belugas
parents: 3733
diff changeset
    47
	return strcmp(buf1, _bufcache); // sort by name
1575
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    48
}
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    49
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 5893
diff changeset
    50
static void GlobalSortSignList()
1575
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    51
{
4349
1016170ae0cb (svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents: 4346
diff changeset
    52
	const Sign *si;
4353
1523114f43f0 (svn r6054) Change the sign sorter in a similar way as the other sorters: Remember a list of pointers to signs instead of a list of SignIDs - This removes a layer of indirection
tron
parents: 4349
diff changeset
    53
	uint n = 0;
1575
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    54
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    55
	/* Create array for sorting */
5609
dc6a58930ba4 (svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents: 5601
diff changeset
    56
	_sign_sort = ReallocT(_sign_sort, GetMaxSignIndex() + 1);
1575
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    57
4353
1523114f43f0 (svn r6054) Change the sign sorter in a similar way as the other sorters: Remember a list of pointers to signs instead of a list of SignIDs - This removes a layer of indirection
tron
parents: 4349
diff changeset
    58
	FOR_ALL_SIGNS(si) _sign_sort[n++] = si;
1523114f43f0 (svn r6054) Change the sign sorter in a similar way as the other sorters: Remember a list of pointers to signs instead of a list of SignIDs - This removes a layer of indirection
tron
parents: 4349
diff changeset
    59
	_num_sign_sort = n;
1523114f43f0 (svn r6054) Change the sign sorter in a similar way as the other sorters: Remember a list of pointers to signs instead of a list of SignIDs - This removes a layer of indirection
tron
parents: 4349
diff changeset
    60
1523114f43f0 (svn r6054) Change the sign sorter in a similar way as the other sorters: Remember a list of pointers to signs instead of a list of SignIDs - This removes a layer of indirection
tron
parents: 4349
diff changeset
    61
	qsort((void*)_sign_sort, n, sizeof(_sign_sort[0]), SignNameSorter);
1575
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    62
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    63
	_sign_sort_dirty = false;
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    64
5380
8ea58542b6e0 (svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents: 5291
diff changeset
    65
	DEBUG(misc, 3, "Resorting global signs list");
1575
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    66
}
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    67
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    68
static void SignListWndProc(Window *w, WindowEvent *e)
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    69
{
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    70
	switch (e->event) {
8927
f04618a15ec7 (svn r12697) -Codechange: give signs_gui.cpp a touch of coding style.
rubidium
parents: 8790
diff changeset
    71
		case WE_PAINT: {
f04618a15ec7 (svn r12697) -Codechange: give signs_gui.cpp a touch of coding style.
rubidium
parents: 8790
diff changeset
    72
			if (_sign_sort_dirty) GlobalSortSignList();
1575
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    73
8927
f04618a15ec7 (svn r12697) -Codechange: give signs_gui.cpp a touch of coding style.
rubidium
parents: 8790
diff changeset
    74
			SetVScrollCount(w, _num_sign_sort);
1575
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    75
8927
f04618a15ec7 (svn r12697) -Codechange: give signs_gui.cpp a touch of coding style.
rubidium
parents: 8790
diff changeset
    76
			SetDParam(0, w->vscroll.count);
f04618a15ec7 (svn r12697) -Codechange: give signs_gui.cpp a touch of coding style.
rubidium
parents: 8790
diff changeset
    77
			DrawWindowWidgets(w);
1575
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    78
8927
f04618a15ec7 (svn r12697) -Codechange: give signs_gui.cpp a touch of coding style.
rubidium
parents: 8790
diff changeset
    79
			/* No signs? */
f04618a15ec7 (svn r12697) -Codechange: give signs_gui.cpp a touch of coding style.
rubidium
parents: 8790
diff changeset
    80
			int y = 16; // offset from top of widget
f04618a15ec7 (svn r12697) -Codechange: give signs_gui.cpp a touch of coding style.
rubidium
parents: 8790
diff changeset
    81
			if (w->vscroll.count == 0) {
f04618a15ec7 (svn r12697) -Codechange: give signs_gui.cpp a touch of coding style.
rubidium
parents: 8790
diff changeset
    82
				DrawString(2, y, STR_304A_NONE, TC_FROMSTRING);
f04618a15ec7 (svn r12697) -Codechange: give signs_gui.cpp a touch of coding style.
rubidium
parents: 8790
diff changeset
    83
				return;
f04618a15ec7 (svn r12697) -Codechange: give signs_gui.cpp a touch of coding style.
rubidium
parents: 8790
diff changeset
    84
			}
1575
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    85
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    86
			/* Start drawing the signs */
8927
f04618a15ec7 (svn r12697) -Codechange: give signs_gui.cpp a touch of coding style.
rubidium
parents: 8790
diff changeset
    87
			for (uint16 i = w->vscroll.pos; i < w->vscroll.cap + w->vscroll.pos && i < w->vscroll.count; i++) {
4353
1523114f43f0 (svn r6054) Change the sign sorter in a similar way as the other sorters: Remember a list of pointers to signs instead of a list of SignIDs - This removes a layer of indirection
tron
parents: 4349
diff changeset
    88
				const Sign *si = _sign_sort[i];
1575
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    89
8927
f04618a15ec7 (svn r12697) -Codechange: give signs_gui.cpp a touch of coding style.
rubidium
parents: 8790
diff changeset
    90
				if (si->owner != OWNER_NONE) DrawPlayerIcon(si->owner, 4, y + 1);
1575
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    91
7056
6daddeaa79df (svn r10321) -Codechange: refer to sign text by index
peter1138
parents: 6420
diff changeset
    92
				SetDParam(0, si->index);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
    93
				DrawString(22, y, STR_SIGN_NAME, TC_YELLOW);
1575
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    94
				y += 10;
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    95
			}
8927
f04618a15ec7 (svn r12697) -Codechange: give signs_gui.cpp a touch of coding style.
rubidium
parents: 8790
diff changeset
    96
		} break;
1575
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    97
8927
f04618a15ec7 (svn r12697) -Codechange: give signs_gui.cpp a touch of coding style.
rubidium
parents: 8790
diff changeset
    98
		case WE_CLICK:
f04618a15ec7 (svn r12697) -Codechange: give signs_gui.cpp a touch of coding style.
rubidium
parents: 8790
diff changeset
    99
			if (e->we.click.widget == 3) {
f04618a15ec7 (svn r12697) -Codechange: give signs_gui.cpp a touch of coding style.
rubidium
parents: 8790
diff changeset
   100
				uint32 id_v = (e->we.click.pt.y - 15) / 10;
1575
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   101
8927
f04618a15ec7 (svn r12697) -Codechange: give signs_gui.cpp a touch of coding style.
rubidium
parents: 8790
diff changeset
   102
				if (id_v >= w->vscroll.cap) return;
f04618a15ec7 (svn r12697) -Codechange: give signs_gui.cpp a touch of coding style.
rubidium
parents: 8790
diff changeset
   103
				id_v += w->vscroll.pos;
f04618a15ec7 (svn r12697) -Codechange: give signs_gui.cpp a touch of coding style.
rubidium
parents: 8790
diff changeset
   104
				if (id_v >= w->vscroll.count) return;
1575
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   105
8927
f04618a15ec7 (svn r12697) -Codechange: give signs_gui.cpp a touch of coding style.
rubidium
parents: 8790
diff changeset
   106
				const Sign *si = _sign_sort[id_v];
f04618a15ec7 (svn r12697) -Codechange: give signs_gui.cpp a touch of coding style.
rubidium
parents: 8790
diff changeset
   107
				ScrollMainWindowToTile(TileVirtXY(si->x, si->y));
f04618a15ec7 (svn r12697) -Codechange: give signs_gui.cpp a touch of coding style.
rubidium
parents: 8790
diff changeset
   108
			}
f04618a15ec7 (svn r12697) -Codechange: give signs_gui.cpp a touch of coding style.
rubidium
parents: 8790
diff changeset
   109
			break;
f04618a15ec7 (svn r12697) -Codechange: give signs_gui.cpp a touch of coding style.
rubidium
parents: 8790
diff changeset
   110
f04618a15ec7 (svn r12697) -Codechange: give signs_gui.cpp a touch of coding style.
rubidium
parents: 8790
diff changeset
   111
		case WE_RESIZE:
f04618a15ec7 (svn r12697) -Codechange: give signs_gui.cpp a touch of coding style.
rubidium
parents: 8790
diff changeset
   112
			w->vscroll.cap += e->we.sizing.diff.y / 10;
f04618a15ec7 (svn r12697) -Codechange: give signs_gui.cpp a touch of coding style.
rubidium
parents: 8790
diff changeset
   113
			break;
1575
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   114
	}
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   115
}
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   116
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   117
static const Widget _sign_list_widget[] = {
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
   118
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,              STR_018B_CLOSE_WINDOW},
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
   119
{    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,   345,     0,    13, STR_SIGN_LIST_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
   120
{  WWT_STICKYBOX,     RESIZE_LR,    14,   346,   357,     0,    13, 0x0,                   STR_STICKY_BUTTON},
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
   121
{      WWT_PANEL,     RESIZE_RB,    14,     0,   345,    14,   137, 0x0,                   STR_NULL},
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
   122
{  WWT_SCROLLBAR,    RESIZE_LRB,    14,   346,   357,    14,   125, 0x0,                   STR_0190_SCROLL_BAR_SCROLLS_LIST},
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4293
diff changeset
   123
{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   346,   357,   126,   137, 0x0,                   STR_RESIZE_BUTTON},
1575
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   124
{   WIDGETS_END},
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   125
};
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   126
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   127
static const WindowDesc _sign_list_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7127
diff changeset
   128
	WDP_AUTO, WDP_AUTO, 358, 138, 358, 138,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5751
diff changeset
   129
	WC_SIGN_LIST, WC_NONE,
1575
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   130
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON | WDF_RESIZABLE,
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   131
	_sign_list_widget,
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   132
	SignListWndProc
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   133
};
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   134
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   135
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 5893
diff changeset
   136
void ShowSignList()
1575
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   137
{
8927
f04618a15ec7 (svn r12697) -Codechange: give signs_gui.cpp a touch of coding style.
rubidium
parents: 8790
diff changeset
   138
	Window *w = AllocateWindowDescFront(&_sign_list_desc, 0);
1575
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   139
	if (w != NULL) {
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   140
		w->vscroll.cap = 12;
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   141
		w->resize.step_height = 10;
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   142
		w->resize.height = w->height - 10 * 7; // minimum if 5 in the list
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   143
	}
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   144
}
7127
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   145
8927
f04618a15ec7 (svn r12697) -Codechange: give signs_gui.cpp a touch of coding style.
rubidium
parents: 8790
diff changeset
   146
/** Edit sign window stuff */
7127
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   147
struct editsign_d : querystr_d {
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   148
	SignID cur_sign;
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   149
};
8749
e32c110d0a77 (svn r12445) -Fix: Add missing compile asserts for window data structs
peter1138
parents: 8737
diff changeset
   150
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(editsign_d));
7127
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   151
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   152
enum QueryEditSignWidgets {
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   153
	QUERY_EDIT_SIGN_WIDGET_TEXT = 3,
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   154
	QUERY_EDIT_SIGN_WIDGET_OK,
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   155
	QUERY_EDIT_SIGN_WIDGET_CANCEL,
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   156
	QUERY_EDIT_SIGN_WIDGET_DELETE,
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   157
	QUERY_EDIT_SIGN_WIDGET_PREVIOUS = QUERY_EDIT_SIGN_WIDGET_DELETE + 2,
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   158
	QUERY_EDIT_SIGN_WIDGET_NEXT,
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   159
};
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   160
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   161
static void UpdateSignEditWindow(Window *w, const Sign *si)
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   162
{
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   163
	/* Display an empty string when the sign hasnt been edited yet */
8258
9fa31acb07bc (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents: 8254
diff changeset
   164
	if (si->name != NULL) {
7127
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   165
		SetDParam(0, si->index);
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   166
		GetString(_edit_str_buf, STR_SIGN_NAME, lastof(_edit_str_buf));
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   167
	} else {
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   168
		GetString(_edit_str_buf, STR_EMPTY, lastof(_edit_str_buf));
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   169
	}
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   170
	_edit_str_buf[lengthof(_edit_str_buf) - 1] = '\0';
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   171
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   172
	WP(w, editsign_d).cur_sign = si->index;
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   173
	InitializeTextBuffer(&WP(w, querystr_d).text, _edit_str_buf, 31, 255); // Allow 31 characters (including \0)
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   174
8028
e578ea22f371 (svn r11588) -Codechange: use the new member introduced in r11551
glx
parents: 8019
diff changeset
   175
	w->InvalidateWidget(QUERY_EDIT_SIGN_WIDGET_TEXT);
7127
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   176
}
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   177
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   178
static void RenameSign(SignID index, const char *text)
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   179
{
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   180
	_cmd_text = text;
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   181
	DoCommandP(0, index, 0, NULL, CMD_RENAME_SIGN | CMD_MSG(STR_280C_CAN_T_CHANGE_SIGN_NAME));
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   182
}
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   183
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   184
static void QuerySignEditWndProc(Window *w, WindowEvent *e)
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   185
{
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   186
	editsign_d *qs = &WP(w, editsign_d);
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   187
	Sign       *si;
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   188
	uint       sign_index = 0;
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   189
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   190
	switch (e->event) {
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   191
		case WE_CREATE:
7931
b0a46cd92225 (svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents: 7929
diff changeset
   192
			SetBit(_no_scroll, SCROLL_EDIT);
7127
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   193
			break;
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   194
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   195
		case WE_PAINT:
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   196
			SetDParam(0, qs->caption);
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   197
			DrawWindowWidgets(w);
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   198
			DrawEditBox(w, qs, QUERY_EDIT_SIGN_WIDGET_TEXT);
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   199
			break;
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   200
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   201
		case WE_CLICK:
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   202
			switch (e->we.click.widget) {
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   203
				case QUERY_EDIT_SIGN_WIDGET_PREVIOUS:
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   204
					if (_sign_sort_dirty) GlobalSortSignList();
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   205
					sign_index = _sign_sort[_num_sign_sort - 1]->index;
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   206
					for (uint i = 1; i < _num_sign_sort; i++) {
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   207
						if (qs->cur_sign == _sign_sort[i]->index) {
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   208
							sign_index = _sign_sort[i - 1]->index;
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   209
							break;
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   210
						}
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   211
					}
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   212
					si = GetSign(sign_index);
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   213
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   214
					/* Scroll to sign and reopen window */
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   215
					ScrollMainWindowToTile(TileVirtXY(si->x, si->y));
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   216
					UpdateSignEditWindow(w, si);
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   217
					break;
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   218
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   219
				case QUERY_EDIT_SIGN_WIDGET_NEXT:
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   220
					if (_sign_sort_dirty) GlobalSortSignList();
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   221
					sign_index = _sign_sort[0]->index;
8969
6d1c74e0e2cd (svn r12761) -Codechange: lots of minor whitespace coding style fixes around operators.
rubidium
parents: 8927
diff changeset
   222
					for (uint i = 0; i < _num_sign_sort - 1; i++) {
7127
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   223
						if (qs->cur_sign == _sign_sort[i]->index) {
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   224
							sign_index = _sign_sort[i + 1]->index;
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   225
							break;
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   226
						}
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   227
					}
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   228
					si = GetSign(sign_index);
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   229
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   230
					/* Scroll to sign and reopen window */
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   231
					ScrollMainWindowToTile(TileVirtXY(si->x, si->y));
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   232
					UpdateSignEditWindow(w, si);
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   233
					break;
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   234
8737
4405e2e80db6 (svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents: 8264
diff changeset
   235
				case QUERY_EDIT_SIGN_WIDGET_TEXT:
4405e2e80db6 (svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents: 8264
diff changeset
   236
					ShowOnScreenKeyboard(w, qs, e->we.click.widget, QUERY_EDIT_SIGN_WIDGET_CANCEL, QUERY_EDIT_SIGN_WIDGET_OK);
4405e2e80db6 (svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents: 8264
diff changeset
   237
					break;
4405e2e80db6 (svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents: 8264
diff changeset
   238
7127
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   239
				case QUERY_EDIT_SIGN_WIDGET_DELETE:
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   240
					/* Only need to set the buffer to null, the rest is handled as the OK button */
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   241
					DeleteTextBufferAll(&qs->text);
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   242
					/* FALL THROUGH */
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   243
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   244
				case QUERY_EDIT_SIGN_WIDGET_OK:
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   245
					RenameSign(qs->cur_sign, qs->text.buf);
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   246
					/* FALL THROUGH */
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   247
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   248
				case QUERY_EDIT_SIGN_WIDGET_CANCEL:
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   249
					DeleteWindow(w);
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   250
					break;
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   251
			}
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   252
			break;
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   253
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   254
		case WE_KEYPRESS:
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   255
			switch (HandleEditBoxKey(w, qs, QUERY_EDIT_SIGN_WIDGET_TEXT, e)) {
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   256
				case 1: // Enter pressed, confirms change
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   257
					RenameSign(qs->cur_sign, qs->text.buf);
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   258
					/* FALL THROUGH */
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   259
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   260
				case 2: // ESC pressed, closes window, abandons changes
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   261
					DeleteWindow(w);
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   262
					break;
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   263
			}
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   264
			break;
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   265
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   266
		case WE_MOUSELOOP:
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   267
			HandleEditBox(w, qs, QUERY_EDIT_SIGN_WIDGET_TEXT);
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   268
			break;
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   269
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   270
		case WE_DESTROY:
7929
6c9b25842b0f (svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13
parents: 7824
diff changeset
   271
			ClrBit(_no_scroll, SCROLL_EDIT);
7127
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   272
			break;
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   273
	}
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   274
}
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   275
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   276
static const Widget _query_sign_edit_widgets[] = {
8737
4405e2e80db6 (svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents: 8264
diff changeset
   277
{ WWT_CLOSEBOX, RESIZE_NONE,  14,   0,  10,   0,  13, STR_00C5,          STR_018B_CLOSE_WINDOW},
4405e2e80db6 (svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents: 8264
diff changeset
   278
{  WWT_CAPTION, RESIZE_NONE,  14,  11, 259,   0,  13, STR_012D,          STR_NULL },
4405e2e80db6 (svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents: 8264
diff changeset
   279
{    WWT_PANEL, RESIZE_NONE,  14,   0, 259,  14,  29, STR_NULL,          STR_NULL },
4405e2e80db6 (svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents: 8264
diff changeset
   280
{  WWT_EDITBOX, RESIZE_NONE,  14,   2, 257,  16,  27, STR_SIGN_OSKTITLE, STR_NULL },  // Text field
4405e2e80db6 (svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents: 8264
diff changeset
   281
{  WWT_TEXTBTN, RESIZE_NONE,  14,   0,  60,  30,  41, STR_012F_OK,       STR_NULL },
4405e2e80db6 (svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents: 8264
diff changeset
   282
{  WWT_TEXTBTN, RESIZE_NONE,  14,  61, 120,  30,  41, STR_012E_CANCEL,   STR_NULL },
4405e2e80db6 (svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents: 8264
diff changeset
   283
{  WWT_TEXTBTN, RESIZE_NONE,  14, 121, 180,  30,  41, STR_0290_DELETE,   STR_NULL },
4405e2e80db6 (svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents: 8264
diff changeset
   284
{    WWT_PANEL, RESIZE_NONE,  14, 181, 237,  30,  41, STR_NULL,          STR_NULL },
4405e2e80db6 (svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents: 8264
diff changeset
   285
{  WWT_TEXTBTN, RESIZE_NONE,  14, 238, 248,  30,  41, STR_6819,          STR_PREVIOUS_SIGN_TOOLTIP },
4405e2e80db6 (svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents: 8264
diff changeset
   286
{  WWT_TEXTBTN, RESIZE_NONE,  14, 249, 259,  30,  41, STR_681A,          STR_NEXT_SIGN_TOOLTIP },
7127
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   287
{ WIDGETS_END },
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   288
};
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   289
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   290
static const WindowDesc _query_sign_edit_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7127
diff changeset
   291
	190, 170, 260, 42, 260, 42,
7127
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   292
	WC_QUERY_STRING, WC_NONE,
8019
fc0e94dee165 (svn r11579) -Revert(r11578): some cases of key propagation are not handled correctly.
belugas
parents: 8018
diff changeset
   293
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
7127
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   294
	_query_sign_edit_widgets,
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   295
	QuerySignEditWndProc
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   296
};
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   297
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   298
void ShowRenameSignWindow(const Sign *si)
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   299
{
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   300
	/* Delete all other edit windows and the save window */
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   301
	DeleteWindowById(WC_QUERY_STRING, 0);
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   302
	DeleteWindowById(WC_SAVELOAD, 0);
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   303
8927
f04618a15ec7 (svn r12697) -Codechange: give signs_gui.cpp a touch of coding style.
rubidium
parents: 8790
diff changeset
   304
	Window *w = AllocateWindowDesc(&_query_sign_edit_desc);
7127
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   305
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   306
	WP(w, editsign_d).caption = STR_280B_EDIT_SIGN_TEXT;
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   307
	WP(w, editsign_d).afilter = CS_ALPHANUMERAL;
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7931
diff changeset
   308
	w->LowerWidget(QUERY_EDIT_SIGN_WIDGET_TEXT);
7127
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   309
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   310
	UpdateSignEditWindow(w, si);
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   311
}