Changeset - r393:57c73ac69034
[Not reviewed]
master
0 6 0
darkvater - 20 years ago 2004-11-14 11:04:59
darkvater@openttd.org
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
6 files changed with 119 insertions and 9 deletions:
0 comments (0 inline, 0 general)
functions.h
Show inline comments
 
@@ -66,6 +66,7 @@ void StationPickerDrawSprite(int x, int 
 

	
 
/* track_land.c */
 
void DrawTrainDepotSprite(int x, int y, int image, int railtype);
 
void DrawCheckpointSprite(int x, int y, int image);
 

	
 
/* road_land.c */
 
void DrawRoadDepotSprite(int x, int y, int image);
lang/czech.txt
Show inline comments
 
@@ -1083,6 +1083,9 @@ STR_CHECKPOINTNAME_CITY						:Kontrolni 
 
STR_CHECKPOINTNAME_CITY_SERIAL					:Kontrolni bod {TOWN} #{COMMA16}
 
STR_LANDINFO_CHECKPOINT						:Kontrolni bod
 

	
 
STR_CHECKPOINT					:{WHITE}Kontrolní bod
 
STR_CHECKPOINT_GRAPHICS_TIP			:{BLACK}Vyber typ kontrolního bodu
 

	
 
STR_CHECKPOINT_VIEWPORT						:{WHITE}{CHECKPOINT}
 
STR_CHECKPOINT_VIEWPORT_TINY					:{TINYFONT}{WHITE}{CHECKPOINT}
 
STR_CHECKPOINT_RAW						:{CHECKPOINT}
lang/english.txt
Show inline comments
 
@@ -1083,6 +1083,9 @@ STR_CHECKPOINTNAME_CITY					:Checkpoint 
 
STR_CHECKPOINTNAME_CITY_SERIAL			:Checkpoint {TOWN} #{COMMA16}
 
STR_LANDINFO_CHECKPOINT					:Checkpoint
 

	
 
STR_CHECKPOINT					:{WHITE}Checkpoint
 
STR_CHECKPOINT_GRAPHICS_TIP			:{BLACK}Select checkpoint type
 

	
 
STR_CHECKPOINT_VIEWPORT					:{WHITE}{CHECKPOINT}
 
STR_CHECKPOINT_VIEWPORT_TINY			:{TINYFONT}{WHITE}{CHECKPOINT}
 
STR_CHECKPOINT_RAW						:{CHECKPOINT}
rail_cmd.c
Show inline comments
 
@@ -1620,6 +1620,35 @@ void DrawTrainDepotSprite(int x, int y, 
 
	}
 
}
 

	
 
void DrawCheckpointSprite(int x, int y, int stat_id)
 
{
 
	// TODO: We should use supersets with cargo-id FF, if available. --pasky
 
	DrawTileSprites *cust = GetCustomStation('WAYP', stat_id);
 
	DrawTileSeqStruct const *seq;
 
	uint32 ormod, img;
 

	
 
	assert(cust);
 

	
 
	// emulate station tile - open with building
 
	// add 1 to get the other direction
 
	cust = &cust[2];
 

	
 
	ormod = SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player));
 

	
 
	x += 33;
 
	y += 17;
 

	
 
	img = cust->ground_sprite;
 
	if (img & 0x8000) img = (img & 0x7FFF);
 
	DrawSprite(img, x, y);
 

	
 
	foreach_draw_tile_seq(seq, cust->seq) {
 
		Point pt = RemapCoords(seq->delta_x, seq->delta_y, seq->delta_z);
 
		DrawSprite((seq->image&0x3FFF) | ormod, x + pt.x, y + pt.y);
 
	}
 
}
 

	
 

	
 
#define NUM_SSD_ENTRY 256
 
#define NUM_SSD_STACK 32
 

	
rail_gui.c
Show inline comments
 
@@ -8,10 +8,13 @@
 
#include "sound.h"
 
#include "command.h"
 
#include "vehicle.h"
 
#include "station.h"
 

	
 
static uint _cur_railtype;
 
static bool _remove_button_clicked;
 
static byte _build_depot_direction;
 
static byte _checkpoint_count;
 
static byte _cur_checkpoint_type;
 

	
 
struct {
 
	byte orientation;
 
@@ -23,6 +26,7 @@ struct {
 

	
 
static void HandleStationPlacement(uint start, uint end);
 
static void ShowBuildTrainDepotPicker();
 
static void ShowBuildCheckpointPicker();
 
static void ShowStationBuilder();
 

	
 
typedef void OnButtonClick(Window *w);
 
@@ -114,12 +118,7 @@ static void PlaceRail_Depot(uint tile)
 
static void PlaceRail_Checkpoint(uint tile)
 
{
 
	if (!_remove_button_clicked) {
 
		/* TODO: We need a graphics selector. In the meantime we use the first
 
		 * custom station ID which works ok with newstats.grf (if you add it
 
		 * to openttd.cfg you want custom checkpoints) and if you don't have
 
		 * any custom station graphics it will fall back to the railstation
 
		 * sprites anyway. --pasky */
 
		DoCommandP(tile, 0x100, 0, CcPlaySound1E, CMD_BUILD_TRAIN_CHECKPOINT | CMD_MSG(STR_CANT_BUILD_TRAIN_CHECKPOINT));
 
		DoCommandP(tile, _checkpoint_count > 0 ? (0x100 + _cur_checkpoint_type) : 0, 0, CcPlaySound1E, CMD_BUILD_TRAIN_CHECKPOINT | CMD_MSG(STR_CANT_BUILD_TRAIN_CHECKPOINT));
 
	} else {
 
		DoCommandP(tile, 0, 0, CcPlaySound1E, CMD_REMOVE_TRAIN_CHECKPOINT | CMD_MSG(STR_CANT_REMOVE_TRAIN_CHECKPOINT));
 
	}
 
@@ -308,7 +307,10 @@ static void BuildRailClick_Sign(Window *
 

	
 
static void BuildRailClick_Checkpoint(Window *w)
 
{
 
	HandlePlacePushButton(w, 18, SPR_OPENTTD_BASE + 7, 1, PlaceRail_Checkpoint);
 
	_checkpoint_count = GetCustomStationsCount('WAYP');
 
	if (HandlePlacePushButton(w, 18, SPR_OPENTTD_BASE + 7, 1, PlaceRail_Checkpoint)
 
	    && _checkpoint_count > 1)
 
		ShowBuildCheckpointPicker();
 
}
 

	
 
static void BuildRailClick_Convert(Window *w)
 
@@ -1052,6 +1054,77 @@ static void ShowBuildTrainDepotPicker()
 
	AllocateWindowDesc(&_build_depot_desc);
 
}
 

	
 

	
 
static void BuildCheckpointWndProc(Window *w, WindowEvent *e)
 
{
 
	switch(e->event) {
 
	case WE_PAINT: {
 
		int r;
 

	
 
		w->click_state = (1 << 3) << _cur_checkpoint_type;
 
		DrawWindowWidgets(w);
 

	
 
		r = 4*w->hscroll.pos;
 
		if(r+0<=_checkpoint_count) DrawCheckpointSprite(2,   25, r + 0);
 
		if(r+1<=_checkpoint_count) DrawCheckpointSprite(70,  25, r + 1);
 
		if(r+2<=_checkpoint_count) DrawCheckpointSprite(138, 25, r + 2);
 
		if(r+3<=_checkpoint_count) DrawCheckpointSprite(206, 25, r + 3);
 
		break;
 
		}
 
	case WE_CLICK: {
 
		switch(e->click.widget) {
 
		case 0:
 
			ResetObjectToPlace();
 
			break;
 
		case 3:
 
		case 4:
 
		case 5:
 
		case 6:
 
			_cur_checkpoint_type = e->click.widget - 3;
 
			SndPlayFx(0x13);
 
			SetWindowDirty(w);
 
			break;
 
		}
 
		break;
 
	}
 
	
 
	case WE_MOUSELOOP:
 
		if (WP(w,def_d).close)
 
			DeleteWindow(w);
 
		return;
 
	}
 
}
 

	
 
static const Widget _build_checkpoint_widgets[] = {
 
{   WWT_CLOSEBOX,     7,     0,    10,     0,    13, STR_00C5, STR_018B_CLOSE_WINDOW},
 
{    WWT_CAPTION,     7,    11,   275,     0,    13, STR_CHECKPOINT,STR_018C_WINDOW_TITLE_DRAG_THIS},
 
{      WWT_PANEL,     7,     0,   275,    14,    91, 0x0, 0},
 

	
 
{      WWT_PANEL,     7,     3,    68,    17,    76, 0x0, STR_CHECKPOINT_GRAPHICS_TIP},
 
{      WWT_PANEL,     7,    71,   136,    17,    76, 0x0, STR_CHECKPOINT_GRAPHICS_TIP},
 
{      WWT_PANEL,     7,   139,   204,    17,    76, 0x0, STR_CHECKPOINT_GRAPHICS_TIP},
 
{      WWT_PANEL,     7,   207,   272,    17,    76, 0x0, STR_CHECKPOINT_GRAPHICS_TIP},
 

	
 
{  WWT_HSCROLLBAR,    7,     1,   275,    80,    91, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
 
{      WWT_LAST},
 
};
 

	
 
static const WindowDesc _build_checkpoint_desc = {
 
	-1,-1, 276, 92,
 
	WC_BUILD_DEPOT,WC_BUILD_TOOLBAR,
 
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
 
	_build_checkpoint_widgets,
 
	BuildCheckpointWndProc
 
};
 

	
 
static void ShowBuildCheckpointPicker()
 
{
 
	Window *w = AllocateWindowDesc(&_build_checkpoint_desc);
 
	w->hscroll.cap = 1;
 
	w->hscroll.count = (uint) (_checkpoint_count+3) / 4;
 
}
 

	
 

	
 
void InitializeRailGui()
 
{
 
	_build_depot_direction = 3;
station.h
Show inline comments
 
@@ -42,11 +42,12 @@ struct Station {
 
	// trainstation width/height
 
	byte trainst_w, trainst_h;
 

	
 
	byte stat_id, class_id;
 
	byte class_id; // custom graphics station class
 
	byte stat_id; // custom graphics station id in the @class_id class
 
	uint16 build_date;
 

	
 
	//uint16 airport_flags;
 
  uint32 airport_flags;
 
	uint32 airport_flags;
 
	uint16 index;
 

	
 
	VehicleID last_vehicle;
0 comments (0 inline, 0 general)