diff options
-rw-r--r-- | main_gui.c | 16 | ||||
-rw-r--r-- | network_client.c | 3 | ||||
-rw-r--r-- | newgrf.c | 4 | ||||
-rw-r--r-- | openttd.h | 161 | ||||
-rw-r--r-- | window.c | 6 | ||||
-rw-r--r-- | window.h | 58 |
6 files changed, 124 insertions, 124 deletions
diff --git a/main_gui.c b/main_gui.c index 845295035..ad28e506b 100644 --- a/main_gui.c +++ b/main_gui.c @@ -43,8 +43,8 @@ #include "network_gui.h" #include "industry.h" -static int _rename_id; -static int _rename_what; +static int _rename_id = 1; +static int _rename_what = -1; static byte _terraform_size = 1; RailType _last_built_railtype; @@ -90,10 +90,12 @@ void HandleOnEditText(WindowEvent *e) } else { NetworkServer_HandleChat(NETWORK_ACTION_GIVE_MONEY, DESTTYPE_TEAM, id, msg, NETWORK_SERVER_INDEX); } - break; - } + } break; #endif /* ENABLE_NETWORK */ + default: NOT_REACHED(); } + + _rename_id = _rename_what = -1; } /** @@ -1840,12 +1842,12 @@ static void MainToolbarWndProc(Window *w, WindowEvent *e) case WE_MOUSELOOP: if (IsWindowWidgetLowered(w, 0) != !!_pause) { ToggleWidgetLoweredState(w, 0); - SetWindowDirty(w); + InvalidateWidget(w, 0); } if (IsWindowWidgetLowered(w, 1) != !!_fast_forward) { ToggleWidgetLoweredState(w, 1); - SetWindowDirty(w); + InvalidateWidget(w, 1); } break; @@ -2371,7 +2373,7 @@ void SetupColorsAndInitialWindow(void) { uint i; Window *w; - int width,height; + int width, height; for (i = 0; i != 16; i++) { const byte *b = GetNonSprite(PALETTE_RECOLOR_START + i); diff --git a/network_client.c b/network_client.c index 1dee26e2d..ef0ae0e03 100644 --- a/network_client.c +++ b/network_client.c @@ -491,8 +491,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_MAP) _network_join_status = NETWORK_JOIN_STATUS_PROCESSING; InvalidateWindow(WC_NETWORK_STATUS_WINDOW, 0); - // The map is done downloading, load it - // Load the map + /* The map is done downloading, load it */ if (!SafeSaveOrLoad(filename, SL_LOAD, GM_NORMAL)) { DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0); _switch_mode_errorstr = STR_NETWORK_ERR_SAVEGAMEERROR; @@ -2483,9 +2483,7 @@ static void SafeInfo(byte *buf, int len) info = name + name_len + 1; info_len = ttd_strnlen(info, len); - if (info_len < len) { - _cur_grfconfig->info = TranslateTTDPatchCodes(info); - } + if (info_len < len) _cur_grfconfig->info = TranslateTTDPatchCodes(info); } } @@ -365,87 +365,86 @@ typedef struct { enum { - WC_MAIN_WINDOW = 0x00, - WC_MAIN_TOOLBAR = 0x01, - WC_STATUS_BAR = 0x02, - WC_BUILD_TOOLBAR = 0x03, - WC_NEWS_WINDOW = 0x04, - WC_TOWN_DIRECTORY = 0x05, - WC_STATION_LIST = 0x06, - WC_TOWN_VIEW = 0x07, - WC_SMALLMAP = 0x08, - WC_TRAINS_LIST = 0x09, - WC_ROADVEH_LIST = 0x0A, - WC_SHIPS_LIST = 0x0B, - WC_AIRCRAFT_LIST = 0x0C, - WC_VEHICLE_VIEW = 0x0D, - WC_VEHICLE_DETAILS = 0x0E, - WC_VEHICLE_REFIT = 0x0F, - WC_VEHICLE_ORDERS = 0x10, - WC_STATION_VIEW = 0x11, - WC_VEHICLE_DEPOT = 0x12, - WC_BUILD_VEHICLE = 0x13, - WC_BUILD_BRIDGE = 0x14, - WC_ERRMSG = 0x15, - WC_ASK_ABANDON_GAME = 0x16, - WC_QUIT_GAME = 0x17, - WC_BUILD_STATION = 0x18, - WC_BUS_STATION = 0x19, - WC_TRUCK_STATION = 0x1A, - WC_BUILD_DEPOT = 0x1B, - WC_COMPANY = 0x1D, - WC_FINANCES = 0x1E, - WC_PLAYER_COLOR = 0x1F, - WC_QUERY_STRING = 0x20, - WC_SAVELOAD = 0x21, - WC_SELECT_GAME = 0x22, - WC_TOOLBAR_MENU = 0x24, - WC_INCOME_GRAPH = 0x25, - WC_OPERATING_PROFIT = 0x26, - WC_TOOLTIPS = 0x27, - WC_INDUSTRY_VIEW = 0x28, - WC_PLAYER_FACE = 0x29, - WC_LAND_INFO = 0x2A, - WC_TOWN_AUTHORITY = 0x2B, - WC_SUBSIDIES_LIST = 0x2C, - WC_GRAPH_LEGEND = 0x2D, - WC_DELIVERED_CARGO = 0x2E, - WC_PERFORMANCE_HISTORY = 0x2F, - WC_COMPANY_VALUE = 0x30, - WC_COMPANY_LEAGUE = 0x31, - WC_BUY_COMPANY = 0x32, - WC_PAYMENT_RATES = 0x33, - WC_ENGINE_PREVIEW = 0x35, - WC_MUSIC_WINDOW = 0x36, - WC_MUSIC_TRACK_SELECTION = 0x37, - WC_SCEN_LAND_GEN = 0x38, // also used for landscaping toolbar - WC_ASK_RESET_LANDSCAPE = 0x39, - WC_SCEN_TOWN_GEN = 0x3A, - WC_SCEN_INDUSTRY = 0x3B, - WC_SCEN_BUILD_ROAD = 0x3C, - WC_BUILD_TREES = 0x3D, - WC_SEND_NETWORK_MSG = 0x3E, - WC_DROPDOWN_MENU = 0x3F, - WC_BUILD_INDUSTRY = 0x40, - WC_GAME_OPTIONS = 0x41, - WC_NETWORK_WINDOW = 0x42, - WC_INDUSTRY_DIRECTORY = 0x43, - WC_MESSAGE_HISTORY = 0x44, - WC_CHEATS = 0x45, - WC_PERFORMANCE_DETAIL = 0x46, - WC_CONSOLE = 0x47, - WC_EXTRA_VIEW_PORT = 0x48, - WC_CLIENT_LIST = 0x49, - WC_NETWORK_STATUS_WINDOW = 0x4A, - WC_CUSTOM_CURRENCY = 0x4B, - WC_REPLACE_VEHICLE = 0x4C, - WC_HIGHSCORE = 0x4D, - WC_ENDSCREEN = 0x4E, - WC_SIGN_LIST = 0x4F, - WC_GENERATE_LANDSCAPE = 0x50, - WC_GENERATE_PROGRESS_WINDOW = 0x51, - WC_OK_CANCEL_QUERY = 0x52, - WC_DEPOT_SELL_ALL = 0x53, + WC_MAIN_WINDOW, + WC_MAIN_TOOLBAR, + WC_STATUS_BAR, + WC_BUILD_TOOLBAR, + WC_NEWS_WINDOW, + WC_TOWN_DIRECTORY, + WC_STATION_LIST, + WC_TOWN_VIEW, + WC_SMALLMAP, + WC_TRAINS_LIST, + WC_ROADVEH_LIST, + WC_SHIPS_LIST, + WC_AIRCRAFT_LIST, + WC_VEHICLE_VIEW, + WC_VEHICLE_DETAILS, + WC_VEHICLE_REFIT, + WC_VEHICLE_ORDERS, + WC_STATION_VIEW, + WC_VEHICLE_DEPOT, + WC_BUILD_VEHICLE, + WC_BUILD_BRIDGE, + WC_ERRMSG, + WC_ASK_ABANDON_GAME, + WC_QUIT_GAME, + WC_BUILD_STATION, + WC_BUS_STATION, + WC_TRUCK_STATION, + WC_BUILD_DEPOT, + WC_COMPANY, + WC_FINANCES, + WC_PLAYER_COLOR, + WC_QUERY_STRING, + WC_SAVELOAD, + WC_SELECT_GAME, + WC_TOOLBAR_MENU, + WC_INCOME_GRAPH, + WC_OPERATING_PROFIT, + WC_TOOLTIPS, + WC_INDUSTRY_VIEW, + WC_PLAYER_FACE, + WC_LAND_INFO, + WC_TOWN_AUTHORITY, + WC_SUBSIDIES_LIST, + WC_GRAPH_LEGEND, + WC_DELIVERED_CARGO, + WC_PERFORMANCE_HISTORY, + WC_COMPANY_VALUE, + WC_COMPANY_LEAGUE, + WC_BUY_COMPANY, + WC_PAYMENT_RATES, + WC_ENGINE_PREVIEW, + WC_MUSIC_WINDOW, + WC_MUSIC_TRACK_SELECTION, + WC_SCEN_LAND_GEN, + WC_SCEN_TOWN_GEN, + WC_SCEN_INDUSTRY, + WC_SCEN_BUILD_ROAD, + WC_BUILD_TREES, + WC_SEND_NETWORK_MSG, + WC_DROPDOWN_MENU, + WC_BUILD_INDUSTRY, + WC_GAME_OPTIONS, + WC_NETWORK_WINDOW, + WC_INDUSTRY_DIRECTORY, + WC_MESSAGE_HISTORY, + WC_CHEATS, + WC_PERFORMANCE_DETAIL, + WC_CONSOLE, + WC_EXTRA_VIEW_PORT, + WC_CLIENT_LIST, + WC_NETWORK_STATUS_WINDOW, + WC_CUSTOM_CURRENCY, + WC_REPLACE_VEHICLE, + WC_HIGHSCORE, + WC_ENDSCREEN, + WC_SIGN_LIST, + WC_GENERATE_LANDSCAPE, + WC_GENERATE_PROGRESS_WINDOW, + WC_OK_CANCEL_QUERY, + WC_DEPOT_SELL_ALL, }; @@ -875,13 +875,15 @@ void InitWindowSystem(void) void UnInitWindowSystem(void) { - Window* const *wz; - // delete all malloced widgets + Window **wz; + /* Delete all malloced widgets, and reset z-array */ FOR_ALL_WINDOWS(wz) { free((*wz)->widget); (*wz)->widget = NULL; (*wz)->widget_count = 0; + *wz = NULL; } + _last_z_window = _z_windows; } void ResetWindowSystem(void) @@ -86,33 +86,33 @@ typedef enum FrameFlags { void DrawFrameRect(int left, int top, int right, int bottom, int color, FrameFlags flags); enum WindowEventCodes { - WE_CLICK = 0, - WE_PAINT = 1, - WE_MOUSELOOP = 2, - WE_TICK = 3, - WE_4 = 4, - WE_TIMEOUT = 5, - WE_PLACE_OBJ = 6, - WE_ABORT_PLACE_OBJ = 7, - WE_DESTROY = 8, - WE_ON_EDIT_TEXT = 9, - WE_POPUPMENU_SELECT = 10, - WE_POPUPMENU_OVER = 11, - WE_DRAGDROP = 12, - WE_PLACE_DRAG = 13, - WE_PLACE_MOUSEUP = 14, - WE_PLACE_PRESIZE = 15, - WE_DROPDOWN_SELECT = 16, - WE_RCLICK = 17, - WE_KEYPRESS = 18, - WE_CREATE = 19, - WE_MOUSEOVER = 20, - WE_ON_EDIT_TEXT_CANCEL = 21, - WE_RESIZE = 22, - WE_MESSAGE = 23, - WE_SCROLL = 24, - WE_MOUSEWHEEL = 25, - WE_INVALIDATE_DATA = 26, + WE_CREATE, + WE_DESTROY, + WE_PAINT, + WE_KEYPRESS, + WE_CLICK, + WE_RCLICK, + WE_MOUSEOVER, + WE_MOUSELOOP, + WE_MOUSEWHEEL, + WE_TICK, + WE_4, + WE_TIMEOUT, + WE_PLACE_OBJ, + WE_ABORT_PLACE_OBJ, + WE_ON_EDIT_TEXT, + WE_ON_EDIT_TEXT_CANCEL, + WE_POPUPMENU_SELECT, + WE_POPUPMENU_OVER, + WE_DRAGDROP, + WE_PLACE_DRAG, + WE_PLACE_MOUSEUP, + WE_PLACE_PRESIZE, + WE_DROPDOWN_SELECT, + WE_RESIZE, + WE_MESSAGE, + WE_SCROLL, + WE_INVALIDATE_DATA, }; struct WindowEvent { @@ -263,7 +263,7 @@ typedef struct WindowDesc { WindowProc *proc; } WindowDesc; -enum { +enum WindowDefaultFlag { WDF_STD_TOOLTIPS = 1, /* use standard routine when displaying tooltips */ WDF_DEF_WIDGET = 2, /* default widget control for some widgets in the on click event */ WDF_STD_BTN = 4, /* default handling for close and drag widgets (widget no 0 and 1) */ @@ -274,7 +274,7 @@ enum { }; /* can be used as x or y coordinates to cause a specific placement */ -enum { +enum WindowDefaultPosition { WDP_AUTO = -1, ///< Find a place automatically WDP_CENTER = -2, ///< Center the window (left/right or top/bottom) WDP_ALIGN_TBR = -3, ///< Align the right side of the window with the right side of the main toolbar |