|
|
@ -321,52 +321,46 @@ void CcCloneShip(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
|
|
|
static void NewShipWndProc(Window *w, WindowEvent *e)
|
|
|
|
static void NewShipWndProc(Window *w, WindowEvent *e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
switch (e->event) {
|
|
|
|
switch (e->event) {
|
|
|
|
case WE_PAINT:
|
|
|
|
case WE_PAINT: {
|
|
|
|
if (w->window_number == 0) w->disabled_state = 1 << 5;
|
|
|
|
EngineID selected_id;
|
|
|
|
|
|
|
|
EngineID eid;
|
|
|
|
|
|
|
|
int count;
|
|
|
|
|
|
|
|
int pos;
|
|
|
|
|
|
|
|
int sel;
|
|
|
|
|
|
|
|
int y;
|
|
|
|
|
|
|
|
|
|
|
|
// Setup scroll count
|
|
|
|
if (w->window_number == 0) w->disabled_state = 1 << 5;
|
|
|
|
{
|
|
|
|
|
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
int num = NUM_SHIP_ENGINES;
|
|
|
|
|
|
|
|
const Engine *eng = GetEngine(SHIP_ENGINES_INDEX);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
do {
|
|
|
|
count = 0;
|
|
|
|
if (HASBIT(eng->player_avail, _local_player)) count++;
|
|
|
|
for (eid = SHIP_ENGINES_INDEX; eid < SHIP_ENGINES_INDEX + NUM_SHIP_ENGINES; eid++) {
|
|
|
|
} while (++eng,--num);
|
|
|
|
if (HASBIT(GetEngine(eid)->player_avail, _local_player)) count++;
|
|
|
|
SetVScrollCount(w, count);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SetVScrollCount(w, count);
|
|
|
|
|
|
|
|
|
|
|
|
DrawWindowWidgets(w);
|
|
|
|
DrawWindowWidgets(w);
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
y = 15;
|
|
|
|
int num = NUM_SHIP_ENGINES;
|
|
|
|
sel = WP(w,buildtrain_d).sel_index;
|
|
|
|
const Engine *eng = GetEngine(SHIP_ENGINES_INDEX);
|
|
|
|
pos = w->vscroll.pos;
|
|
|
|
int x = 2;
|
|
|
|
selected_id = INVALID_ENGINE;
|
|
|
|
int y = 15;
|
|
|
|
for (eid = SHIP_ENGINES_INDEX; eid < SHIP_ENGINES_INDEX + NUM_SHIP_ENGINES; eid++) {
|
|
|
|
int sel = WP(w,buildtrain_d).sel_index;
|
|
|
|
if (!HASBIT(GetEngine(eid)->player_avail, _local_player)) continue;
|
|
|
|
int pos = w->vscroll.pos;
|
|
|
|
if (sel == 0) selected_id = eid;
|
|
|
|
EngineID engine_id = SHIP_ENGINES_INDEX;
|
|
|
|
|
|
|
|
EngineID selected_id = INVALID_ENGINE;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
do {
|
|
|
|
|
|
|
|
if (HASBIT(eng->player_avail, _local_player)) {
|
|
|
|
|
|
|
|
if (sel==0) selected_id = engine_id;
|
|
|
|
|
|
|
|
if (IS_INT_INSIDE(--pos, -w->vscroll.cap, 0)) {
|
|
|
|
if (IS_INT_INSIDE(--pos, -w->vscroll.cap, 0)) {
|
|
|
|
DrawString(x+75, y+7, GetCustomEngineName(engine_id), sel==0 ? 0xC : 0x10);
|
|
|
|
DrawString(77, y + 7, GetCustomEngineName(eid), sel == 0 ? 0xC : 0x10);
|
|
|
|
DrawShipEngine(x+35, y+10, engine_id, GetEnginePalette(engine_id, _local_player));
|
|
|
|
DrawShipEngine(37, y + 10, eid, GetEnginePalette(eid, _local_player));
|
|
|
|
y += 24;
|
|
|
|
y += 24;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sel--;
|
|
|
|
sel--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while (++engine_id, ++eng,--num);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WP(w,buildtrain_d).sel_engine = selected_id;
|
|
|
|
WP(w,buildtrain_d).sel_engine = selected_id;
|
|
|
|
|
|
|
|
|
|
|
|
if (selected_id != INVALID_ENGINE) {
|
|
|
|
if (selected_id != INVALID_ENGINE) {
|
|
|
|
DrawShipPurchaseInfo(2, w->widget[4].top + 1, selected_id);
|
|
|
|
DrawShipPurchaseInfo(2, w->widget[4].top + 1, selected_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case WE_CLICK:
|
|
|
|
case WE_CLICK:
|
|
|
|
switch (e->click.widget) {
|
|
|
|
switch (e->click.widget) {
|
|
|
|