Skip to content

Commit

Permalink
CHG: single_info now tiles the windows. If there is a convoi or halt,…
Browse files Browse the repository at this point in the history
… not way or other info will be shown (default for Android)

git-svn-id: svn://tron.homeunix.org/simutrans/simutrans/trunk@11339 8aca7d54-2c30-db11-9de9-000461428c89
  • Loading branch information
prissi committed Jul 13, 2024
1 parent 5dce97e commit 502de28
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 22 deletions.
1 change: 1 addition & 0 deletions simutrans/history.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
ADD: restore open windows when rejoining a network game
ADD: restore pakset symbols after changing the gui skin
CHG: don't save default player colours with the settings/game, use pakset simuconf.tab only
CHG: single_info now tiles the windows. If there is a convoi or halt, not way or other info will be shown (default for Android)


Release of 124.1 (r11272 on 3-June-2024):
Expand Down
20 changes: 19 additions & 1 deletion src/simutrans/dataobj/environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ std::string env_t::pak_name;
sint16 env_t::menupos = MENU_TOP;
bool env_t::single_toolbar_mode = false;
sint16 env_t::dpi_scale = 100;
bool env_t::single_info = 1;
#else
sint16 env_t::menupos = MENU_BOTTOM;
bool env_t::single_toolbar_mode = true;
sint16 env_t::dpi_scale = -1;
bool env_t::single_info = 0;
#endif
sint16 env_t::fullscreen = WINDOWED;
sint16 env_t::display_scale_percent = 100;
Expand Down Expand Up @@ -140,7 +142,6 @@ bool env_t::tree_info;
bool env_t::ground_info;
uint8 env_t::show_factory_storage_bar;
bool env_t::townhall_info;
bool env_t::single_info;
bool env_t::single_line_gui;
bool env_t::window_buttons_right;
bool env_t::second_open_closes_win;
Expand Down Expand Up @@ -344,6 +345,23 @@ void env_t::init()
listen.append_unique("::");
listen.append_unique("0.0.0.0");
show_money_message = 0;

#ifndef __ANDROID__
env_t::menupos = MENU_TOP;
env_t::single_toolbar_mode = false;
env_t::dpi_scale = 100;
env_t::single_info = 1;
env_t::hide_keyboard = false;

#else
// here for Android
env_t::menupos = MENU_BOTTOM;
env_t::single_toolbar_mode = true;
env_t::dpi_scale = -1;
env_t::single_info = 0;
// autoshow keyboard on textinput
env_t::hide_keyboard = true;
#endif
}


Expand Down
12 changes: 11 additions & 1 deletion src/simutrans/gui/simwin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1425,7 +1425,17 @@ void win_set_pos(gui_frame_t *gui, scr_coord new_pos)
{
for( uint32 i = wins.get_count(); i-- != 0; ) {
if( wins[i].gui == gui ) {
wins[i].pos = new_pos;
// Allow snap to screen edge
scr_coord other_pos( (env_t::menupos == MENU_LEFT) * env_t::iconsize.w, (env_t::menupos == MENU_TOP) * env_t::iconsize.h + (env_t::menupos == MENU_BOTTOM) * win_get_statusbar_height());
scr_size other_size( display_get_width() - other_pos.x - (env_t::menupos == MENU_RIGHT) * env_t::iconsize.w,
display_get_height() - win_get_statusbar_height() - env_t::iconsize.h);
if (show_ticker) {
other_size.h -= TICKER_HEIGHT;
}
scr_rect screen(other_pos, other_size);
scr_rect window(new_pos, gui->get_windowsize());
window.clip(screen);
wins[i].pos = window.get_pos();
wins[i].dirty = true;
return;
}
Expand Down
91 changes: 71 additions & 20 deletions src/simutrans/tool/simtool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -353,70 +353,121 @@ static grund_t *tool_intern_koord_to_weg_grund(player_t *player, karte_t *welt,


/****************************************** now the actual tools **************************************/


const char *tool_query_t::work( player_t *, koord3d pos )
{
grund_t *gr = welt->lookup(pos);
minivec_tpl<gui_frame_t*>info;

if(gr) {
// not single_info: show least important first
const bool reverse = !env_t::single_info || is_ctrl_pressed();
minivec_tpl<convoihandle_t>convois;
const bool reverse = is_ctrl_pressed();

// iterate through different stages of importance
const uint8 max_stages = 4;
for(uint8 stage = 0; stage<max_stages; stage++) {
const uint8 max_stages = 5;
for(uint8 stage = 0; stage<5; stage++) {

uint32 old_count = win_get_open_count();

switch (reverse ? max_stages-1-stage: stage) {
case 0: { // halts
case 0: // halts
if( gr->get_halt().is_bound() ) {
gr->get_halt()->open_info_window();
if (old_count < win_get_open_count()) {
info.append(win_get_top());
}
}
break;
}

case 1: // labels
if( gr->get_flag(grund_t::marked) ) {
label_t *lb = gr->find<label_t>();
if( lb ) {
if(label_t *lb = gr->find<label_t>()) {
lb->show_info();
if( old_count < win_get_open_count() ) {
return NULL;
info.append(win_get_top());
}
}
}
break;
case 2: { // objects
convoihandle_t cnv;

case 2: // convois
for (uint8 n = gr->get_top(); n-- != 0;) {
obj_t *obj = gr->obj_bei(reverse ? gr->get_top()-1-n : n);
obj_t* obj = gr->obj_bei(reverse ? gr->get_top() - 1 - n : n);

if (vehicle_t* veh = dynamic_cast<vehicle_t*>(obj)) {
if (veh->get_convoi()->self == cnv) {
continue; // do not try to open the same window twice, does not work so great with env_t::second_open_closes_win
convois.append_unique(veh->get_convoi()->self);
}
}
for (uint8 n = 0; n < convois.get_count(); n++) {
convois[n]->open_info_window();
if (old_count < win_get_open_count()) {
if (env_t::single_info) {
return NULL;
}
cnv = veh->get_convoi()->self;
info.append(win_get_top());
}
}
break;

case 3: // objects
for (uint8 n = gr->get_top(); n-- != 0;) {
obj_t* obj = gr->obj_bei(reverse ? gr->get_top() - 1 - n : n);

if (vehicle_t* veh = dynamic_cast<vehicle_t*>(obj)) {
// already openend them
continue;
}
if( obj && obj->get_typ()!=obj_t::wayobj && obj->get_typ()!=obj_t::pillar && obj->get_typ()!=obj_t::label ) {
if (obj && obj->get_typ() != obj_t::wayobj && obj->get_typ() != obj_t::pillar && obj->get_typ() != obj_t::label) {
DBG_MESSAGE("tool_query_t()", "index %u", (unsigned)n);
obj->show_info();
// did some new window open?
if(env_t::single_info && old_count < win_get_open_count()) {
return NULL;
if (old_count < win_get_open_count()) {
if (env_t::single_info) {
return NULL;
}
info.append(win_get_top());
}
old_count = win_get_open_count(); // click may have closed a window, open a new one if possible
}
}
break;
}
case 3:

case 4:
default: // ground
gr->open_info_window();
if (old_count < win_get_open_count()) {
info.append(win_get_top());
}
break;
}

if( env_t::single_info && old_count < win_get_open_count() ) {
if( env_t::single_info && !info.empty()) {
return NULL;
}
if(stage==2 && !info.empty()) {
// we have a station, label or convois => do not show roads until next click
break;
}
}
}
if (info.get_count() == 2) {
scr_coord pos = welt->get_viewport()->get_screen_coord(gr->get_pos());
// try to tile the windows
win_set_pos(info[0], pos - scr_size(info[0]->get_windowsize().w,info[0]->get_windowsize().h/2));
win_set_pos(info[1], pos - scr_size(0, info[1]->get_windowsize().h/2));
}
else if (info.get_count() > 2) {
scr_coord pos = welt->get_viewport()->get_screen_coord(gr->get_pos());
// try to tile the windows
win_set_pos(info[0], pos - info[0]->get_windowsize());
win_set_pos(info[1], pos - scr_size(0, info[1]->get_windowsize().h));
win_set_pos(info[2], pos - scr_size(info[2]->get_windowsize().w,0));
if (info.get_count() > 3) {
win_set_pos(info[3], pos);
}
// the rest will sit on top of each other
}
return NULL;
}
Expand Down

0 comments on commit 502de28

Please sign in to comment.