src/signs_gui.cpp
author rubidium
Sat, 12 Jan 2008 14:10:35 +0000
changeset 8254 1496654ca5e7
parent 8224 c5a64d87cc54
child 8258 9fa31acb07bc
permissions -rw-r--r--
(svn r11818) -Codechange: split player.h into smaller pieces.
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
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
     3
/** @file signs_gui.cpp */
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"
507
04b5403aaf6b (svn r815) Include strings.h only in the files which need it.
tron
parents: 410
diff changeset
     7
#include "table/strings.h"
2187
a0e206ce9fbf (svn r2702) -Codechange: Cleaned up the sprite code and replaced many magic numbers
celestar
parents: 2186
diff changeset
     8
#include "table/sprites.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     9
#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
    10
#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
    11
#include "window_gui.h"
8254
1496654ca5e7 (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8224
diff changeset
    12
#include "player_gui.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 "signs.h"
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    14
#include "debug.h"
2159
f6284cf5fab0 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 2135
diff changeset
    15
#include "variables.h"
8116
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents: 8114
diff changeset
    16
#include "command_func.h"
8114
dd6d21dc99c1 (svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents: 8107
diff changeset
    17
#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
    18
#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
    19
#include "window_func.h"
8139
4e91c448c409 (svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium
parents: 8131
diff changeset
    20
#include "map_func.h"
8224
c5a64d87cc54 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8139
diff changeset
    21
#include "gfx_func.h"
c5a64d87cc54 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8139
diff changeset
    22
#include "viewport_func.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    23
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
    24
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
    25
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
    26
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    27
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
    28
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
    29
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    30
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
    31
{
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
    32
	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
    33
	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
    34
	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
    35
4912
0f51b47cb983 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4911
diff changeset
    36
	GetString(buf1, sign0->str, 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
    37
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
    38
	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
    39
		_last_sign = sign1;
4912
0f51b47cb983 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4911
diff changeset
    40
		GetString(_bufcache, sign1->str, 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
    41
	}
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    42
3801
4307270e7100 (svn r4809) Codechange : Merged two loops in only one.
belugas
parents: 3733
diff changeset
    43
	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
    44
}
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    45
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 5893
diff changeset
    46
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
    47
{
4349
1016170ae0cb (svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents: 4346
diff changeset
    48
	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
    49
	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
    50
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    51
	/* 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
    52
	_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
    53
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
    54
	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
    55
	_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
    56
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
    57
	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
    58
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    59
	_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
    60
5380
8ea58542b6e0 (svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents: 5291
diff changeset
    61
	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
    62
}
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    63
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    64
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
    65
{
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    66
	switch (e->event) {
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    67
	case WE_PAINT: {
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    68
		int y = 16; // offset from top of widget
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
		if (_sign_sort_dirty)
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    71
			GlobalSortSignList();
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    72
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    73
		SetVScrollCount(w, _num_sign_sort);
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    74
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    75
		SetDParam(0, w->vscroll.count);
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    76
		DrawWindowWidgets(w);
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    77
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    78
		/* No signs? */
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    79
		if (w->vscroll.count == 0) {
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
    80
			DrawString(2, y, STR_304A_NONE, TC_FROMSTRING);
1575
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    81
			return;
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    82
		}
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    83
4349
1016170ae0cb (svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents: 4346
diff changeset
    84
		{
2135
08120c3cf43e (svn r2645) Fix (useless)warning in graph_gui and add brackets around HASBIT in an if statement
Darkvater
parents: 2133
diff changeset
    85
			uint16 i;
1575
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    86
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    87
			/* Start drawing the signs */
2133
d7f582b7001d (svn r2643) Get rid of some unnecessary casts
tron
parents: 2063
diff changeset
    88
			for (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
    89
				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
    90
4349
1016170ae0cb (svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents: 4346
diff changeset
    91
				if (si->owner != OWNER_NONE)
1016170ae0cb (svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents: 4346
diff changeset
    92
					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
    93
7056
6daddeaa79df (svn r10321) -Codechange: refer to sign text by index
peter1138
parents: 6420
diff changeset
    94
				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
    95
				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
    96
				y += 10;
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    97
			}
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    98
		}
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
    99
	} break;
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   100
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   101
	case WE_CLICK: {
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4444
diff changeset
   102
		switch (e->we.click.widget) {
1575
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   103
		case 3: {
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4444
diff changeset
   104
			uint32 id_v = (e->we.click.pt.y - 15) / 10;
4349
1016170ae0cb (svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents: 4346
diff changeset
   105
			const Sign *si;
1575
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   106
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   107
			if (id_v >= w->vscroll.cap)
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   108
				return;
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   109
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   110
			id_v += w->vscroll.pos;
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   111
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   112
			if (id_v >= w->vscroll.count)
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   113
				return;
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   114
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
   115
			si = _sign_sort[id_v];
4349
1016170ae0cb (svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents: 4346
diff changeset
   116
			ScrollMainWindowToTile(TileVirtXY(si->x, si->y));
1575
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   117
		} break;
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   118
		}
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   119
	} break;
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   120
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   121
	case WE_RESIZE:
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4444
diff changeset
   122
		w->vscroll.cap += e->we.sizing.diff.y / 10;
1575
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   123
		break;
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   124
	}
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 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
   128
{   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
   129
{    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
   130
{  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
   131
{      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
   132
{  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
   133
{  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
   134
{   WIDGETS_END},
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   135
};
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   136
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   137
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
   138
	WDP_AUTO, WDP_AUTO, 358, 138, 358, 138,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5751
diff changeset
   139
	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
   140
	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
   141
	_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
   142
	SignListWndProc
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
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   145
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 5893
diff changeset
   146
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
   147
{
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   148
	Window *w;
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   149
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   150
	w = AllocateWindowDescFront(&_sign_list_desc, 0);
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   151
	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
   152
		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
   153
		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
   154
		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
   155
	}
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1130
diff changeset
   156
}
7127
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   157
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   158
/* Edit sign window stuff */
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
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
   161
	SignID cur_sign;
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
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   164
static char _edit_str_buf[64];
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   165
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   166
enum QueryEditSignWidgets {
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   167
	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
   168
	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
   169
	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
   170
	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
   171
	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
   172
	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
   173
};
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   174
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   175
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
   176
{
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   177
	/* Display an empty string when the sign hasnt been edited yet */
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   178
	if (si->str != STR_280A_SIGN) {
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   179
		SetDParam(0, si->index);
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   180
		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
   181
	} else {
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   182
		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
   183
	}
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   184
	_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
   185
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   186
	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
   187
	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
   188
8028
e578ea22f371 (svn r11588) -Codechange: use the new member introduced in r11551
glx
parents: 8019
diff changeset
   189
	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
   190
}
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   191
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   192
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
   193
{
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   194
	_cmd_text = text;
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   195
	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
   196
}
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   197
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   198
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
   199
{
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   200
	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
   201
	Sign       *si;
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   202
	uint       sign_index = 0;
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   203
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   204
	switch (e->event) {
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   205
		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
   206
			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
   207
			break;
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   208
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   209
		case WE_PAINT:
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   210
			SetDParam(0, qs->caption);
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   211
			DrawWindowWidgets(w);
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   212
			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
   213
			break;
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   214
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   215
		case WE_CLICK:
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   216
			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
   217
				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
   218
					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
   219
					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
   220
					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
   221
						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
   222
							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
   223
							break;
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   224
						}
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   225
					}
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   226
					si = GetSign(sign_index);
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
					/* 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
   229
					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
   230
					UpdateSignEditWindow(w, si);
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   231
					break;
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   232
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   233
				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
   234
					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
   235
					sign_index = _sign_sort[0]->index;
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   236
					for (uint i = 0; i < _num_sign_sort-1; i++) {
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   237
						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
   238
							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
   239
							break;
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   240
						}
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   241
					}
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   242
					si = GetSign(sign_index);
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
					/* 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
   245
					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
   246
					UpdateSignEditWindow(w, si);
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   247
					break;
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   248
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   249
				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
   250
					/* 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
   251
					DeleteTextBufferAll(&qs->text);
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   252
					/* FALL THROUGH */
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 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
   255
					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
   256
					/* FALL THROUGH */
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   257
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   258
				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
   259
					DeleteWindow(w);
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   260
					break;
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   261
			}
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
		case WE_KEYPRESS:
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   265
			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
   266
				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
   267
					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
   268
					/* FALL THROUGH */
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 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
   271
					DeleteWindow(w);
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
			break;
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
		case WE_MOUSELOOP:
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   277
			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
   278
			break;
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   279
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   280
		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
   281
			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
   282
			break;
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   283
	}
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   284
}
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   285
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   286
static const Widget _query_sign_edit_widgets[] = {
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   287
{ WWT_CLOSEBOX, RESIZE_NONE,  14,   0,  10,   0,  13, STR_00C5,        STR_018B_CLOSE_WINDOW},
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   288
{  WWT_CAPTION, RESIZE_NONE,  14,  11, 259,   0,  13, STR_012D,        STR_NULL },
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   289
{    WWT_PANEL, RESIZE_NONE,  14,   0, 259,  14,  29, STR_NULL,        STR_NULL },
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   290
{    WWT_PANEL, RESIZE_NONE,  14,   2, 257,  16,  27, STR_NULL,        STR_NULL },  // Text field
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   291
{  WWT_TEXTBTN, RESIZE_NONE,  14,   0,  60,  30,  41, STR_012F_OK,     STR_NULL },
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   292
{  WWT_TEXTBTN, RESIZE_NONE,  14,  61, 120,  30,  41, STR_012E_CANCEL, STR_NULL },
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   293
{  WWT_TEXTBTN, RESIZE_NONE,  14, 121, 180,  30,  41, STR_0290_DELETE, STR_NULL },
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   294
{    WWT_PANEL, RESIZE_NONE,  14, 181, 237,  30,  41, STR_NULL,        STR_NULL },
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   295
{  WWT_TEXTBTN, RESIZE_NONE,  14, 238, 248,  30,  41, STR_6819,        STR_PREVIOUS_SIGN_TOOLTIP },
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   296
{  WWT_TEXTBTN, RESIZE_NONE,  14, 249, 259,  30,  41, STR_681A,        STR_NEXT_SIGN_TOOLTIP },
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   297
{ WIDGETS_END },
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   298
};
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
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
   301
	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
   302
	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
   303
	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
   304
	_query_sign_edit_widgets,
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   305
	QuerySignEditWndProc
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   306
};
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   307
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   308
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
   309
{
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   310
	Window *w;
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   311
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   312
	/* 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
   313
	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
   314
	DeleteWindowById(WC_SAVELOAD, 0);
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   315
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   316
	w = AllocateWindowDesc(&_query_sign_edit_desc);
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   317
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   318
	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
   319
	WP(w, editsign_d).afilter = CS_ALPHANUMERAL;
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7931
diff changeset
   320
	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
   321
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   322
	UpdateSignEditWindow(w, si);
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   323
}
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   324
86924644d78a (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 7056
diff changeset
   325
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
   326