author | rubidium |
Fri, 03 Aug 2007 22:09:42 +0000 | |
branch | noai |
changeset 9694 | e72987579514 |
parent 9631 | 8a2d1c2ceb88 |
child 8320 | 6ffad7a5d242 |
child 9722 | ebf0ece7d8f6 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
9574 | 3 |
/** @file signs_gui.cpp */ |
4 |
||
0 | 5 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1575
diff
changeset
|
6 |
#include "openttd.h" |
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
410
diff
changeset
|
7 |
#include "table/strings.h" |
2187
2a51f8925eeb
(svn r2702) -Codechange: Cleaned up the sprite code and replaced many magic numbers
celestar
parents:
2186
diff
changeset
|
8 |
#include "table/sprites.h" |
2163
637ec3c361f5
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
9 |
#include "functions.h" |
0 | 10 |
#include "window.h" |
11 |
#include "gui.h" |
|
12 |
#include "gfx.h" |
|
13 |
#include "player.h" |
|
1575
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
14 |
#include "signs.h" |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
15 |
#include "strings.h" |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
16 |
#include "debug.h" |
2159
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2135
diff
changeset
|
17 |
#include "variables.h" |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
18 |
#include "helpers.hpp" |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
19 |
#include "command.h" |
0 | 20 |
|
4353
2b941f2c325c
(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
|
21 |
static const Sign **_sign_sort; |
2b941f2c325c
(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
|
22 |
static uint _num_sign_sort; |
1575
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
23 |
|
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
24 |
static char _bufcache[64]; |
4353
2b941f2c325c
(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 const Sign *_last_sign; |
1575
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
26 |
|
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
27 |
static int CDECL SignNameSorter(const void *a, const void *b) |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
28 |
{ |
4353
2b941f2c325c
(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
|
29 |
const Sign *sign0 = *(const Sign**)a; |
2b941f2c325c
(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 |
const Sign *sign1 = *(const Sign**)b; |
1575
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
31 |
char buf1[64]; |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
32 |
|
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4911
diff
changeset
|
33 |
GetString(buf1, sign0->str, lastof(buf1)); |
1575
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
34 |
|
4353
2b941f2c325c
(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 |
if (sign1 != _last_sign) { |
2b941f2c325c
(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
|
36 |
_last_sign = sign1; |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4911
diff
changeset
|
37 |
GetString(_bufcache, sign1->str, lastof(_bufcache)); |
1575
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
38 |
} |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
39 |
|
3801
866d8cb1d707
(svn r4809) Codechange : Merged two loops in only one.
belugas
parents:
3733
diff
changeset
|
40 |
return strcmp(buf1, _bufcache); // sort by name |
1575
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
41 |
} |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
42 |
|
6573 | 43 |
static void GlobalSortSignList() |
1575
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
44 |
{ |
4349
2fc39ff2626e
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
45 |
const Sign *si; |
4353
2b941f2c325c
(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
|
46 |
uint n = 0; |
1575
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
47 |
|
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
48 |
/* Create array for sorting */ |
5860
7fdc9b423ba1
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5852
diff
changeset
|
49 |
_sign_sort = ReallocT(_sign_sort, GetMaxSignIndex() + 1); |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5291
diff
changeset
|
50 |
if (_sign_sort == NULL) error("Could not allocate memory for the sign-sorting-list"); |
1575
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
51 |
|
4353
2b941f2c325c
(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
|
52 |
FOR_ALL_SIGNS(si) _sign_sort[n++] = si; |
2b941f2c325c
(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 |
_num_sign_sort = n; |
2b941f2c325c
(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 |
|
2b941f2c325c
(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 |
qsort((void*)_sign_sort, n, sizeof(_sign_sort[0]), SignNameSorter); |
1575
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
56 |
|
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
57 |
_sign_sort_dirty = false; |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
58 |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5291
diff
changeset
|
59 |
DEBUG(misc, 3, "Resorting global signs list"); |
1575
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
60 |
} |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
61 |
|
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
62 |
static void SignListWndProc(Window *w, WindowEvent *e) |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
63 |
{ |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
64 |
switch (e->event) { |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
65 |
case WE_PAINT: { |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
66 |
int y = 16; // offset from top of widget |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
67 |
|
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
68 |
if (_sign_sort_dirty) |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
69 |
GlobalSortSignList(); |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
70 |
|
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
71 |
SetVScrollCount(w, _num_sign_sort); |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
72 |
|
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
73 |
SetDParam(0, w->vscroll.count); |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
74 |
DrawWindowWidgets(w); |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
75 |
|
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
76 |
/* No signs? */ |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
77 |
if (w->vscroll.count == 0) { |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
78 |
DrawString(2, y, STR_304A_NONE, 0); |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
79 |
return; |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
80 |
} |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
81 |
|
4349
2fc39ff2626e
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
82 |
{ |
2135
48fb9f0322cb
(svn r2645) Fix (useless)warning in graph_gui and add brackets around HASBIT in an if statement
Darkvater
parents:
2133
diff
changeset
|
83 |
uint16 i; |
1575
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
84 |
|
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
85 |
/* Start drawing the signs */ |
2133 | 86 |
for (i = w->vscroll.pos; i < w->vscroll.cap + w->vscroll.pos && i < w->vscroll.count; i++) { |
4353
2b941f2c325c
(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
|
87 |
const Sign *si = _sign_sort[i]; |
1575
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
88 |
|
4349
2fc39ff2626e
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
89 |
if (si->owner != OWNER_NONE) |
2fc39ff2626e
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
90 |
DrawPlayerIcon(si->owner, 4, y + 1); |
1575
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
91 |
|
9629 | 92 |
SetDParam(0, si->index); |
93 |
DrawString(22, y, STR_SIGN_NAME, 8); |
|
1575
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
94 |
y += 10; |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
95 |
} |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
96 |
} |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
97 |
} break; |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
98 |
|
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
99 |
case WE_CLICK: { |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4444
diff
changeset
|
100 |
switch (e->we.click.widget) { |
1575
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
101 |
case 3: { |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4444
diff
changeset
|
102 |
uint32 id_v = (e->we.click.pt.y - 15) / 10; |
4349
2fc39ff2626e
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
103 |
const Sign *si; |
1575
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
104 |
|
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
105 |
if (id_v >= w->vscroll.cap) |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
106 |
return; |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
107 |
|
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
108 |
id_v += w->vscroll.pos; |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
109 |
|
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
110 |
if (id_v >= w->vscroll.count) |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
111 |
return; |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
112 |
|
4353
2b941f2c325c
(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
|
113 |
si = _sign_sort[id_v]; |
4349
2fc39ff2626e
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
114 |
ScrollMainWindowToTile(TileVirtXY(si->x, si->y)); |
1575
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
115 |
} break; |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
116 |
} |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
117 |
} break; |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
118 |
|
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
119 |
case WE_RESIZE: |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4444
diff
changeset
|
120 |
w->vscroll.cap += e->we.sizing.diff.y / 10; |
1575
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
121 |
break; |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
122 |
} |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
123 |
} |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
124 |
|
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
125 |
static const Widget _sign_list_widget[] = { |
4344
5d0e40cd67b9
(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
|
126 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5d0e40cd67b9
(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
|
127 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 345, 0, 13, STR_SIGN_LIST_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
5d0e40cd67b9
(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_STICKYBOX, RESIZE_LR, 14, 346, 357, 0, 13, 0x0, STR_STICKY_BUTTON}, |
5d0e40cd67b9
(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_PANEL, RESIZE_RB, 14, 0, 345, 14, 137, 0x0, STR_NULL}, |
5d0e40cd67b9
(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_SCROLLBAR, RESIZE_LRB, 14, 346, 357, 14, 125, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
5d0e40cd67b9
(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_RESIZEBOX, RESIZE_LRTB, 14, 346, 357, 126, 137, 0x0, STR_RESIZE_BUTTON}, |
1575
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
132 |
{ WIDGETS_END}, |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
133 |
}; |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
134 |
|
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
135 |
static const WindowDesc _sign_list_desc = { |
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9631
diff
changeset
|
136 |
WDP_AUTO, WDP_AUTO, 358, 138, 358, 138, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6002
diff
changeset
|
137 |
WC_SIGN_LIST, WC_NONE, |
1575
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
138 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
139 |
_sign_list_widget, |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
140 |
SignListWndProc |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
141 |
}; |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
142 |
|
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
143 |
|
6573 | 144 |
void ShowSignList() |
1575
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
145 |
{ |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
146 |
Window *w; |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
147 |
|
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
148 |
w = AllocateWindowDescFront(&_sign_list_desc, 0); |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
149 |
if (w != NULL) { |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
150 |
w->vscroll.cap = 12; |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
151 |
w->resize.step_height = 10; |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
152 |
w->resize.height = w->height - 10 * 7; // minimum if 5 in the list |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
153 |
} |
a566a645401f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1130
diff
changeset
|
154 |
} |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
155 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
156 |
/* Edit sign window stuff */ |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
157 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
158 |
struct editsign_d : querystr_d { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
159 |
SignID cur_sign; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
160 |
}; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
161 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
162 |
static char _edit_str_buf[64]; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
163 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
164 |
enum QueryEditSignWidgets { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
165 |
QUERY_EDIT_SIGN_WIDGET_TEXT = 3, |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
166 |
QUERY_EDIT_SIGN_WIDGET_OK, |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
167 |
QUERY_EDIT_SIGN_WIDGET_CANCEL, |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
168 |
QUERY_EDIT_SIGN_WIDGET_DELETE, |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
169 |
QUERY_EDIT_SIGN_WIDGET_PREVIOUS = QUERY_EDIT_SIGN_WIDGET_DELETE + 2, |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
170 |
QUERY_EDIT_SIGN_WIDGET_NEXT, |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
171 |
}; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
172 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
173 |
static void UpdateSignEditWindow(Window *w, const Sign *si) |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
174 |
{ |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
175 |
/* Display an empty string when the sign hasnt been edited yet */ |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
176 |
if (si->str != STR_280A_SIGN) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
177 |
SetDParam(0, si->index); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
178 |
GetString(_edit_str_buf, STR_SIGN_NAME, lastof(_edit_str_buf)); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
179 |
} else { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
180 |
GetString(_edit_str_buf, STR_EMPTY, lastof(_edit_str_buf)); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
181 |
} |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
182 |
_edit_str_buf[lengthof(_edit_str_buf) - 1] = '\0'; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
183 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
184 |
WP(w, editsign_d).cur_sign = si->index; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
185 |
InitializeTextBuffer(&WP(w, querystr_d).text, _edit_str_buf, 31, 255); // Allow 31 characters (including \0) |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
186 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
187 |
InvalidateWidget(w, QUERY_EDIT_SIGN_WIDGET_TEXT); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
188 |
} |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
189 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
190 |
static void RenameSign(SignID index, const char *text) |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
191 |
{ |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
192 |
_cmd_text = text; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
193 |
DoCommandP(0, index, 0, NULL, CMD_RENAME_SIGN | CMD_MSG(STR_280C_CAN_T_CHANGE_SIGN_NAME)); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
194 |
} |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
195 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
196 |
static void QuerySignEditWndProc(Window *w, WindowEvent *e) |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
197 |
{ |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
198 |
editsign_d *qs = &WP(w, editsign_d); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
199 |
Sign *si; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
200 |
uint sign_index = 0; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
201 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
202 |
switch (e->event) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
203 |
case WE_CREATE: |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
204 |
SETBIT(_no_scroll, SCROLL_EDIT); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
205 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
206 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
207 |
case WE_PAINT: |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
208 |
SetDParam(0, qs->caption); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
209 |
DrawWindowWidgets(w); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
210 |
DrawEditBox(w, qs, QUERY_EDIT_SIGN_WIDGET_TEXT); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
211 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
212 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
213 |
case WE_CLICK: |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
214 |
switch (e->we.click.widget) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
215 |
case QUERY_EDIT_SIGN_WIDGET_PREVIOUS: |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
216 |
if (_sign_sort_dirty) GlobalSortSignList(); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
217 |
sign_index = _sign_sort[_num_sign_sort - 1]->index; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
218 |
for (uint i = 1; i < _num_sign_sort; i++) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
219 |
if (qs->cur_sign == _sign_sort[i]->index) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
220 |
sign_index = _sign_sort[i - 1]->index; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
221 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
222 |
} |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
223 |
} |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
224 |
si = GetSign(sign_index); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
225 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
226 |
/* Scroll to sign and reopen window */ |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
227 |
ScrollMainWindowToTile(TileVirtXY(si->x, si->y)); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
228 |
UpdateSignEditWindow(w, si); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
229 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
230 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
231 |
case QUERY_EDIT_SIGN_WIDGET_NEXT: |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
232 |
if (_sign_sort_dirty) GlobalSortSignList(); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
233 |
sign_index = _sign_sort[0]->index; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
234 |
for (uint i = 0; i < _num_sign_sort-1; i++) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
235 |
if (qs->cur_sign == _sign_sort[i]->index) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
236 |
sign_index = _sign_sort[i + 1]->index; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
237 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
238 |
} |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
239 |
} |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
240 |
si = GetSign(sign_index); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
241 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
242 |
/* Scroll to sign and reopen window */ |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
243 |
ScrollMainWindowToTile(TileVirtXY(si->x, si->y)); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
244 |
UpdateSignEditWindow(w, si); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
245 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
246 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
247 |
case QUERY_EDIT_SIGN_WIDGET_DELETE: |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
248 |
/* Only need to set the buffer to null, the rest is handled as the OK button */ |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
249 |
DeleteTextBufferAll(&qs->text); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
250 |
/* FALL THROUGH */ |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
251 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
252 |
case QUERY_EDIT_SIGN_WIDGET_OK: |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
253 |
RenameSign(qs->cur_sign, qs->text.buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
254 |
/* FALL THROUGH */ |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
255 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
256 |
case QUERY_EDIT_SIGN_WIDGET_CANCEL: |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
257 |
DeleteWindow(w); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
258 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
259 |
} |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
260 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
261 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
262 |
case WE_KEYPRESS: |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
263 |
switch (HandleEditBoxKey(w, qs, QUERY_EDIT_SIGN_WIDGET_TEXT, e)) { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
264 |
case 1: // Enter pressed, confirms change |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
265 |
RenameSign(qs->cur_sign, qs->text.buf); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
266 |
/* FALL THROUGH */ |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
267 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
268 |
case 2: // ESC pressed, closes window, abandons changes |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
269 |
DeleteWindow(w); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
270 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
271 |
} |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
272 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
273 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
274 |
case WE_MOUSELOOP: |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
275 |
HandleEditBox(w, qs, QUERY_EDIT_SIGN_WIDGET_TEXT); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
276 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
277 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
278 |
case WE_DESTROY: |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
279 |
CLRBIT(_no_scroll, SCROLL_EDIT); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
280 |
break; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
281 |
} |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
282 |
} |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
283 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
284 |
static const Widget _query_sign_edit_widgets[] = { |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
285 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
286 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 259, 0, 13, STR_012D, STR_NULL }, |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
287 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 259, 14, 29, STR_NULL, STR_NULL }, |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
288 |
{ WWT_PANEL, RESIZE_NONE, 14, 2, 257, 16, 27, STR_NULL, STR_NULL }, // Text field |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
289 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 60, 30, 41, STR_012F_OK, STR_NULL }, |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
290 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 61, 120, 30, 41, STR_012E_CANCEL, STR_NULL }, |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
291 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 121, 180, 30, 41, STR_0290_DELETE, STR_NULL }, |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
292 |
{ WWT_PANEL, RESIZE_NONE, 14, 181, 237, 30, 41, STR_NULL, STR_NULL }, |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
293 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 238, 248, 30, 41, STR_6819, STR_PREVIOUS_SIGN_TOOLTIP }, |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
294 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 249, 259, 30, 41, STR_681A, STR_NEXT_SIGN_TOOLTIP }, |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
295 |
{ WIDGETS_END }, |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
296 |
}; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
297 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
298 |
static const WindowDesc _query_sign_edit_desc = { |
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9631
diff
changeset
|
299 |
190, 170, 260, 42, 260, 42, |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
300 |
WC_QUERY_STRING, WC_NONE, |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
301 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
302 |
_query_sign_edit_widgets, |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
303 |
QuerySignEditWndProc |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
304 |
}; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
305 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
306 |
void ShowRenameSignWindow(const Sign *si) |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
307 |
{ |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
308 |
Window *w; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
309 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
310 |
/* Delete all other edit windows and the save window */ |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
311 |
DeleteWindowById(WC_QUERY_STRING, 0); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
312 |
DeleteWindowById(WC_SAVELOAD, 0); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
313 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
314 |
w = AllocateWindowDesc(&_query_sign_edit_desc); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
315 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
316 |
WP(w, editsign_d).caption = STR_280B_EDIT_SIGN_TEXT; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
317 |
WP(w, editsign_d).afilter = CS_ALPHANUMERAL; |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
318 |
LowerWindowWidget(w, QUERY_EDIT_SIGN_WIDGET_TEXT); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
319 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
320 |
UpdateSignEditWindow(w, si); |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
321 |
} |
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
322 |
|
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
323 |