1
0
Fork 0

(svn r6938) -Codechange: Comments, typo, variable naming, whitespace, strecpy and simplification

of order_gui (only disable a single widget if not local player, all others aren't
 visible anyways).
release/0.5
Darkvater 2006-10-24 23:11:40 +00:00
parent b63d946898
commit 93599c1be5
3 changed files with 37 additions and 32 deletions

24
gfx.c
View File

@ -33,22 +33,19 @@ static byte _string_colorremap[3];
#define DIRTY_BYTES_PER_LINE (MAX_SCREEN_WIDTH / 64) #define DIRTY_BYTES_PER_LINE (MAX_SCREEN_WIDTH / 64)
static byte _dirty_blocks[DIRTY_BYTES_PER_LINE * MAX_SCREEN_HEIGHT / 8]; static byte _dirty_blocks[DIRTY_BYTES_PER_LINE * MAX_SCREEN_HEIGHT / 8];
void memcpy_pitch(void *dst, void *src, int w, int h, int srcpitch, int dstpitch)
void memcpy_pitch(void *d, void *s, int w, int h, int spitch, int dpitch)
{ {
byte *dp = (byte*)d; byte *dstp = (byte*)dst;
byte *sp = (byte*)s; byte *srcp = (byte*)src;
assert(h >= 0); assert(h >= 0);
for (; h != 0; --h) { for (; h != 0; --h) {
memcpy(dp, sp, w); memcpy(dstp, srcp, w);
dp += dpitch; dstp += dstpitch;
sp += spitch; srcp += srcpitch;
} }
} }
void GfxScroll(int left, int top, int width, int height, int xo, int yo) void GfxScroll(int left, int top, int width, int height, int xo, int yo)
{ {
const Pixel *src; const Pixel *src;
@ -583,7 +580,14 @@ BoundingRect GetStringBoundingBox(const char *str)
return br; return br;
} }
/** Draw a string at the given coordinates with the given colour
* @param string the string to draw
* @param x offset from left side of the screen, if negative offset from the right side
* @param x offset from top side of the screen, if negative offset from the bottom
* @param real_color colour of the string, see _string_colormap in
* table/palettes.h or docs/ottd-colourtext-palette.png
* @return the x-coordinates where the drawing has finished. If nothing is drawn
* the originally passed x-coordinate is returned */
int DoDrawString(const char *string, int x, int y, uint16 real_color) int DoDrawString(const char *string, int x, int y, uint16 real_color)
{ {
DrawPixelInfo *dpi = _cur_dpi; DrawPixelInfo *dpi = _cur_dpi;

View File

@ -1094,12 +1094,12 @@ void ShowQueryString(StringID str, StringID caption, uint maxlen, uint maxwidth,
w = AllocateWindowDesc(&_query_string_desc); w = AllocateWindowDesc(&_query_string_desc);
GetString(_edit_str_buf, str, lastof(_edit_str_buf)); GetString(_edit_str_buf, str, lastof(_edit_str_buf));
_edit_str_buf[realmaxlen-1] = '\0'; _edit_str_buf[realmaxlen - 1] = '\0';
if (maxlen & 0x1000) { if (maxlen & 0x1000) {
WP(w, querystr_d).orig = NULL; WP(w, querystr_d).orig = NULL;
} else { } else {
strcpy(_orig_str_buf, _edit_str_buf); strecpy(_orig_str_buf, _edit_str_buf, lastof(_orig_str_buf));
WP(w, querystr_d).orig = _orig_str_buf; WP(w, querystr_d).orig = _orig_str_buf;
} }

View File

@ -57,11 +57,9 @@ static void DrawOrdersWindow(Window *w)
int sel; int sel;
int y, i; int y, i;
bool shared_orders; bool shared_orders;
bool not_localplayer;
byte color; byte color;
v = GetVehicle(w->window_number); v = GetVehicle(w->window_number);
not_localplayer = v->owner != _local_player;
shared_orders = IsOrderListShared(v); shared_orders = IsOrderListShared(v);
@ -72,31 +70,32 @@ static void DrawOrdersWindow(Window *w)
order = GetVehicleOrder(v, sel); order = GetVehicleOrder(v, sel);
/* skip */ if (v->owner == _local_player) {
SetWindowWidgetDisabledState(w, 4, not_localplayer || v->num_orders == 0); /* skip */
SetWindowWidgetDisabledState(w, 4, v->num_orders == 0);
/* delete */ /* delete */
SetWindowWidgetDisabledState(w, 5, not_localplayer || SetWindowWidgetDisabledState(w, 5,
(uint)v->num_orders + (shared_orders ? 1 : 0) <= (uint)WP(w, order_d).sel); (uint)v->num_orders + (shared_orders ? 1 : 0) <= (uint)WP(w, order_d).sel);
/* non-stop only for trains */
SetWindowWidgetDisabledState(w, 6, not_localplayer || v->type != VEH_Train
|| order == NULL);
SetWindowWidgetDisabledState(w, 7, not_localplayer); // go-to
SetWindowWidgetDisabledState(w, 8, not_localplayer || order == NULL); // full load
SetWindowWidgetDisabledState(w, 9, not_localplayer || order == NULL); // unload
SetWindowWidgetDisabledState(w, 10, not_localplayer || order == NULL); // transfer
SetWindowWidgetDisabledState(w, 11, !shared_orders || v->orders == NULL); // Disable list of vehicles with the same shared orders if there are no list
SetWindowWidgetDisabledState(w, 12, not_localplayer || order == NULL); // Refit
/* non-stop only for trains */
SetWindowWidgetDisabledState(w, 6, v->type != VEH_Train || order == NULL);
SetWindowWidgetDisabledState(w, 8, order == NULL); // full load
SetWindowWidgetDisabledState(w, 9, order == NULL); // unload
SetWindowWidgetDisabledState(w, 10, order == NULL); // transfer
/* Disable list of vehicles with the same shared orders if there is no list */
SetWindowWidgetDisabledState(w, 11, !shared_orders || v->orders == NULL);
SetWindowWidgetDisabledState(w, 12, order == NULL); // Refit
} else {
DisableWindowWidget(w, 10);
}
ShowWindowWidget(w, 9); // Unload ShowWindowWidget(w, 9); // Unload
HideWindowWidget(w, 12); // Refit HideWindowWidget(w, 12); // Refit
if (order != NULL) { if (order != NULL) {
switch (order->type) { switch (order->type) {
case OT_GOTO_STATION: case OT_GOTO_STATION: break;
break;
case OT_GOTO_DEPOT: case OT_GOTO_DEPOT:
DisableWindowWidget(w, 10); DisableWindowWidget(w, 10);
@ -495,6 +494,8 @@ static void OrdersWndProc(Window *w, WindowEvent *e)
Vehicle *v = GetVehicle(w->window_number); Vehicle *v = GetVehicle(w->window_number);
uint i; uint i;
if (v->owner != _local_player) break;
for (i = 0; i < lengthof(_order_keycodes); i++) { for (i = 0; i < lengthof(_order_keycodes); i++) {
if (e->we.keypress.keycode == _order_keycodes[i]) { if (e->we.keypress.keycode == _order_keycodes[i]) {
e->we.keypress.cont = false; e->we.keypress.cont = false;
@ -536,7 +537,7 @@ static void OrdersWndProc(Window *w, WindowEvent *e)
* This is because of all open order windows WE_MOUSELOOP is called * This is because of all open order windows WE_MOUSELOOP is called
* and if you have 3 windows open, and this check is not done * and if you have 3 windows open, and this check is not done
* the order is copied to the last open window instead of the * the order is copied to the last open window instead of the
* one where GOTO is enalbed * one where GOTO is enabled
*/ */
if (v != NULL && IsWindowWidgetLowered(w, 7)) { if (v != NULL && IsWindowWidgetLowered(w, 7)) {
_place_clicked_vehicle = NULL; _place_clicked_vehicle = NULL;