mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-09 19:10:38 +00:00
(svn r11918) -Codechange: Draw engine lists at widget positions instead of fixed pixel positions
This commit is contained in:
parent
22a7b95c10
commit
70025a149d
@ -334,13 +334,13 @@ static void ReplaceVehicleWndProc(Window *w, WindowEvent *e)
|
|||||||
|
|
||||||
/* Draw the lists */
|
/* Draw the lists */
|
||||||
for(byte i = 0; i < 2; i++) {
|
for(byte i = 0; i < 2; i++) {
|
||||||
uint16 x = i == 0 ? 2 : 230; // at what X offset
|
uint widget = (i == 0) ? RVW_WIDGET_LEFT_MATRIX : RVW_WIDGET_RIGHT_MATRIX;
|
||||||
EngineList list = WP(w, replaceveh_d).list[i]; // which list to draw
|
EngineList list = WP(w, replaceveh_d).list[i]; // which list to draw
|
||||||
EngineID start = i == 0 ? w->vscroll.pos : w->vscroll2.pos; // what is the offset for the start (scrolling)
|
EngineID start = i == 0 ? w->vscroll.pos : w->vscroll2.pos; // what is the offset for the start (scrolling)
|
||||||
EngineID end = min((i == 0 ? w->vscroll.cap : w->vscroll2.cap) + start, EngList_Count(&list));
|
EngineID end = min((i == 0 ? w->vscroll.cap : w->vscroll2.cap) + start, EngList_Count(&list));
|
||||||
|
|
||||||
/* Do the actual drawing */
|
/* Do the actual drawing */
|
||||||
DrawEngineList((VehicleType)w->window_number, x, 15, list, start, end, WP(w, replaceveh_d).sel_engine[i], i == 0, selected_group);
|
DrawEngineList((VehicleType)w->window_number, w->widget[widget].left + 2, w->widget[widget].top + 1, list, start, end, WP(w, replaceveh_d).sel_engine[i], i == 0, selected_group);
|
||||||
|
|
||||||
/* Also draw the details if an engine is selected */
|
/* Also draw the details if an engine is selected */
|
||||||
if (WP(w, replaceveh_d).sel_engine[i] != INVALID_ENGINE) {
|
if (WP(w, replaceveh_d).sel_engine[i] != INVALID_ENGINE) {
|
||||||
|
@ -986,7 +986,7 @@ static void DrawBuildVehicleWindow(Window *w)
|
|||||||
|
|
||||||
DrawWindowWidgets(w);
|
DrawWindowWidgets(w);
|
||||||
|
|
||||||
DrawEngineList(bv->vehicle_type, 2, 27, bv->eng_list, w->vscroll.pos, max, bv->sel_engine, false, DEFAULT_GROUP);
|
DrawEngineList(bv->vehicle_type, w->widget[BUILD_VEHICLE_WIDGET_LIST].left + 2, w->widget[BUILD_VEHICLE_WIDGET_LIST].top + 1, bv->eng_list, w->vscroll.pos, max, bv->sel_engine, false, DEFAULT_GROUP);
|
||||||
|
|
||||||
if (bv->sel_engine != INVALID_ENGINE) {
|
if (bv->sel_engine != INVALID_ENGINE) {
|
||||||
const Widget *wi = &w->widget[BUILD_VEHICLE_WIDGET_PANEL];
|
const Widget *wi = &w->widget[BUILD_VEHICLE_WIDGET_PANEL];
|
||||||
@ -1011,7 +1011,7 @@ static void BuildVehicleClickEvent(Window *w, WindowEvent *e)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case BUILD_VEHICLE_WIDGET_LIST: {
|
case BUILD_VEHICLE_WIDGET_LIST: {
|
||||||
uint i = (e->we.click.pt.y - 26) / GetVehicleListHeight(bv->vehicle_type) + w->vscroll.pos;
|
uint i = (e->we.click.pt.y - w->widget[BUILD_VEHICLE_WIDGET_LIST].top) / GetVehicleListHeight(bv->vehicle_type) + w->vscroll.pos;
|
||||||
uint num_items = EngList_Count(&bv->eng_list);
|
uint num_items = EngList_Count(&bv->eng_list);
|
||||||
bv->sel_engine = (i < num_items) ? bv->eng_list[i] : INVALID_ENGINE;
|
bv->sel_engine = (i < num_items) ? bv->eng_list[i] : INVALID_ENGINE;
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
|
Loading…
Reference in New Issue
Block a user