The International Simutrans Forum

 

Author Topic: [Patch] New underground view  (Read 51204 times)

0 Members and 1 Guest are viewing this topic.

Offline VS

  • Senior Plumber (Devotee)
  • Devotees (Inactive)
  • *
  • Posts: 4856
  • Vladimír Slávik
    • VS's Simutrans site
  • Languages: CS,EN
Re: [Patch] New underground view
« Reply #105 on: May 14, 2009, 08:20:12 AM »
Dwachs - just making sure, I did not mean program-wise, only the GUI. That would make it actually look like one mode, regardless of implementation...

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10691
  • Languages: De,EN,JP
Re: [Patch] New underground view
« Reply #106 on: May 14, 2009, 08:44:40 AM »
I want to play around with the underground mode a little bit myself, before submitting it. I never did so far really test the usability and so on.

Switching between normal view and sliced view is not a bad idea. This would only add commands for slicingup/down and turning off would be automatic. But there needs to be and additional interface as visual indication. Maybe in the lower right border just above the ticker line in slice mode there will be two arrows and a number. Not a real popup.


Offline z9999

  • Devotees (Inactive)
  • *
  • Posts: 848
Re: [Patch] New underground view
« Reply #107 on: May 14, 2009, 03:49:40 PM »
Quote
== if switching to underground, the height of the tile under the cursor will be taken as underground-level

This works well with keyboard shortcut and very useful, I like this.
But if we clicked on toolbar button to toggle height-cut view, height will be the height of behind toolbar button. In many cases, this height not what we wanted to see, and also up and down height one by one is very heavy for large map.
This is frustration about current UI.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4878
  • Languages: EN, DE, AT
Re: [Patch] New underground view
« Reply #108 on: May 14, 2009, 05:33:35 PM »
This works well with keyboard shortcut and very useful, I like this.
But if we clicked on toolbar button to toggle height-cut view, height will be the height of behind toolbar button. In many cases, this height not what we wanted to see, and also up and down height one by one is very heavy for large map.
This is frustration about current UI.

in this case one can use the last selected height or the height of the tile in the middle of the screen.

what do you mean is frustrating?

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4878
  • Languages: EN, DE, AT
Re: [Patch] New underground view
« Reply #109 on: May 30, 2009, 12:05:41 PM »

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4878
  • Languages: EN, DE, AT
Re: [Patch] New underground view
« Reply #110 on: June 15, 2009, 07:04:51 PM »
New version of the patch:

http://simutrans-germany.com/~patches/upload/underground-2518.patch

I modified the toggling of the different view. Now there is only one tool that does the job: general_tool[34] or simple_tool[15].
Both are identic, except that general tools can have cursors etc, which a simple-tool (the original underground toggle) does not have.

Here is my modification of the pak64 menuconf.tab, which explains the use of the tools and its parameters. All tools (except with parameter K) can be realized with buttons in a toolbar. All tools (except C) can be toggled by keyboard only.
Code: [Select]
# assign a cursor image to the underground tool
general_tool[34]=,7,,

# ...
# add underground tools as invisible tools to the main toolbar
# 0) with parameter U .. toggles complete undergroundview (key U here)
toolbar[0][27]=general_tool[34],,U,U
# 1) with parameter I .. increases slice height with key HOME
toolbar[0][27]=general_tool[34],,HOME,I
# 2) with parameter D .. decreases slice height with key END
toolbar[0][28]=general_tool[34],,END,D
# 3) with parameter K .. toggles sliced view with height taken from tile under cursor (key ctrl-u)
toolbar[0][29]=general_tool[34],,^U,K
# 4) with parameter K .. toggles sliced view with height taken from tile under cursor by an extra mouse click (key ctrl-c)
toolbar[0][30]=general_tool[34],,^C,C

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10691
  • Languages: De,EN,JP
Re: [Patch] New underground view
« Reply #111 on: June 15, 2009, 07:10:19 PM »
I will have a look at it today. Not sure, if the one tool idea survives though.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4878
  • Languages: EN, DE, AT
Re: [Patch] New underground view
« Reply #112 on: June 15, 2009, 07:17:11 PM »
I re-uploaded the patch.

The patch needs several strings to be translated:

two error messages:
Code: [Select]
Terraforming not possible\nhere in underground view
Cannot built this station/building\nin underground mode here.
tooltips:
Code: [Select]
sliced underground mode
decrease underground view level
increase underground view level

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10691
  • Languages: De,EN,JP
Re: [Patch] New underground view
« Reply #113 on: June 15, 2009, 10:21:02 PM »
Submitted, but there is still an error, if I lower the slice below sealevel by the manual tools (even though this might be useful, if harbourtunnels will be forbidden to built in next versions).

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20818
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: [Patch] New underground view
« Reply #114 on: June 16, 2009, 12:22:31 AM »
Excellent - I am very glad to see this incorporated into the trunk. One or two questions and comments if I may:

1. Does this incorporate the underground slopes patch?

2. Is it possible to change the colour for the shading of the 3d cursor in pakset configuration files (rather than the code), and, if so, where?

3. Might I suggest that an option be added to be able to change heights by CTRL+scroll wheel instead of or as well as the HOME/END keys?

4. One somewhat unintuitive aspect of this feature is the fact that, at any given level of underground view, no lower layers are shown, even if there is nothing on top of them. Might I suggest that, in a future release, all layers under the surface of the ground are considered transparent so that it is possible to see multiple underground layers at once? This would be different from the old underground view, in that, whilst one would see all underground layers at or below the current view height level, one would not see the higher underground layers, if any. Nonetheless, such a feature, I think, would be more intuitive and assist with the design of underground networks.

Thank you all those who have worked on this excellent patch :-)

Offline Isaac Eiland-Hall

  • Benevolent Dictator
  • Administrator
  • *
  • Posts: 3924
  • Providing hosting for Simutrans projects
    • pc2.io
  • Languages: EN
Re: [Patch] New underground view
« Reply #115 on: June 16, 2009, 04:44:51 AM »
Does this imply that we will be able to tunnel under the ocean?

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4878
  • Languages: EN, DE, AT
Re: [Patch] New underground view
« Reply #116 on: June 16, 2009, 05:12:28 AM »
Does this imply that we will be able to tunnel under the ocean?
No, not yet. But in some future maybe. There is a patch around, which needs updating.

2. Is it possible to change the colour for the shading of the 3d cursor in pakset configuration files (rather than the code), and, if so, where?
You can specify the cursor_overlay_color in simuconf.tab. Or what else do you mean?

Quote
3. Might I suggest that an option be added to be able to change heights by CTRL+scroll wheel instead of or as well as the HOME/END keys?
You can at least change HOME/End to other keys in menuconf.tab. I dont know whether ctrl+scroll will work or not, or is wanted or not.

Submitted, but there is still an error, if I lower the slice below sealevel by the manual tools (even though this might be useful, if harbourtunnels will be forbidden to built in next versions).
I corrected this, however a nice way to impose restrictions on the slice level is still missing...
« Last Edit: June 16, 2009, 06:36:42 AM by Isaac.Eiland-Hall »

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20818
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: [Patch] New underground view
« Reply #117 on: June 16, 2009, 07:57:17 AM »
Dwachs,

thank you for the replies :-) The cursor_overlay_color setting: does that require numbers or words? I.e., ought one set cursor_overlay_color=1024 (etc.) or cursor_overlay_color=yellow?

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4878
  • Languages: EN, DE, AT

Offline z9999

  • Devotees (Inactive)
  • *
  • Posts: 848
Re: [Patch] New underground view
« Reply #119 on: June 16, 2009, 11:46:06 AM »
It is very nice to show height level on menu button. Thank you, I like this veru much.

BTW, does draw_after() could show images too ? For example, showing compass azimuth on WKZ_ROTATE90 button.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10691
  • Languages: De,EN,JP
Re: [Patch] New underground view
« Reply #120 on: June 16, 2009, 01:34:09 PM »
THis should be possible, if the required images are loaded. For instance if there is image 7,8,9,10 in simple tools, but only the first is used for the tool, then it could just display (icon+rotation) for the new image number. (They are registered consequtively.)

Offline z9999

  • Devotees (Inactive)
  • *
  • Posts: 848
Re: [Patch] New underground view
« Reply #121 on: June 16, 2009, 01:39:55 PM »
Problem:
1. Toggle slice mode
2. Up/Down slice mode
3. Toggle slice mode
Result:
It will be full undeerground mode instead of overground mode.

[edit]
Another problems

1. Toggle on slice mode
2. Toggle on underground mode
3. Toggle off underground mode
Result:
It will be overground mode instead of slice mode

Toggle mode with "K" key doesn't toggle mode.
« Last Edit: June 16, 2009, 01:59:52 PM by z9999 »

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4878
  • Languages: EN, DE, AT
Re: [Patch] New underground view
« Reply #122 on: June 16, 2009, 02:16:01 PM »
Yes you are right, this has to be modified for true toggling. I will look into that tonight.

Offline z9999

  • Devotees (Inactive)
  • *
  • Posts: 848
Re: [Patch] New underground view
« Reply #123 on: June 17, 2009, 05:00:14 PM »
My patch for this.
http://simutrans-germany.com/files/upload/0008-slice-fixed.patch.txt

Code: [Select]
diff --git a/gui/colors.cc b/gui/colors.cc
index 949993c..1a63daa 100644
--- a/gui/colors.cc
+++ b/gui/colors.cc
@@ -22,44 +22,45 @@
 
 #include "../utils/simstring.h"
 
-#define MAX_BUTTONS (20)
+#define MAX_BUTTONS (21)
 
 // y coordinates
 #define GRID_MODE (0*13+6)
 #define UNDERGROUND (1*13+6)
-#define DAY_NIGHT (2*13+6)
-#define BRIGHTNESS (3*13+6)
-#define SCROLL_INVERS (4*13+6)
-#define SCROLL_SPEED (5*13+6)
+#define SLICE (2*13+6)
+#define DAY_NIGHT (3*13+6)
+#define BRIGHTNESS (4*13+6)
+#define SCROLL_INVERS (5*13+6)
+#define SCROLL_SPEED (6*13+6)
 
-#define SEPERATE1 (6*13+6)
+#define SEPERATE1 (7*13+6)
 
-#define USE_TRANSPARENCY (6*13+6+4)
-#define HIDE_TREES (7*13+6+4)
-#define HIDE_CITY_HOUSES (8*13+6+4)
+#define USE_TRANSPARENCY (7*13+6+4)
+#define HIDE_TREES (8*13+6+4)
+#define HIDE_CITY_HOUSES (9*13+6+4)
 
-#define SEPERATE2 (9*13+6+4)
+#define SEPERATE2 (10*13+6+4)
 
-#define USE_TRANSPARENCY_STATIONS (9*13+6+2*4)
-#define SHOW_STATION_COVERAGE (10*13+6+2*4)
-#define SHOW_STATION_SIGNS (11*13+6+2*4)
-#define SHOW_STATION_GOODS (12*13+6+2*4)
+#define USE_TRANSPARENCY_STATIONS (10*13+6+2*4)
+#define SHOW_STATION_COVERAGE (11*13+6+2*4)
+#define SHOW_STATION_SIGNS (12*13+6+2*4)
+#define SHOW_STATION_GOODS (13*13+6+2*4)
 
-#define SEPERATE3 (13*13+6+2*4)
+#define SEPERATE3 (14*13+6+2*4)
 
-#define CITY_WALKER (13*13+6+3*4)
-#define STOP_WALKER (14*13+6+3*4)
-#define DENS_TRAFFIC (15*13+6+3*4)
-#define CONVOI_TOOLTIPS (16*13+6+3*4)
+#define CITY_WALKER (14*13+6+3*4)
+#define STOP_WALKER (15*13+6+3*4)
+#define DENS_TRAFFIC (16*13+6+3*4)
+#define CONVOI_TOOLTIPS (17*13+6+3*4)
 
-#define SEPERATE4 (17*13+6+3*4)
+#define SEPERATE4 (18*13+6+3*4)
 
-#define FPS_DATA (17*13+6+4*4)
-#define IDLE_DATA (18*13+6+4*4)
-#define FRAME_DATA (19*13+6+4*4)
-#define LOOP_DATA (20*13+6+4*4)
+#define FPS_DATA (18*13+6+4*4)
+#define IDLE_DATA (19*13+6+4*4)
+#define FRAME_DATA (20*13+6+4*4)
+#define LOOP_DATA (21*13+6+4*4)
 
-#define BOTTOM (21*13+6+12+5*4)
+#define BOTTOM (22*13+6+12+5*4)
 
 // x coordinates
 #define RIGHT_WIDTH (220)
@@ -145,14 +146,6 @@ color_gui_t::color_gui_t(karte_t *welt) :
  buttons[16].set_typ(button_t::square_state);
  buttons[16].set_text("underground mode");
 
- inp_underground_level.set_pos(koord(NUMBER_INP, UNDERGROUND) );
- inp_underground_level.set_groesse( koord(50,12));
- inp_underground_level.set_value( grund_t::underground_level );
- inp_underground_level.set_limits(welt->get_grundwasser(), 20);
- add_komponente(&inp_underground_level);
- inp_underground_level.add_listener(this);
-
-
  buttons[17].set_pos( koord(10,GRID_MODE) );
  buttons[17].set_typ(button_t::square_state);
  buttons[17].set_text("show grid");
@@ -167,6 +160,17 @@ color_gui_t::color_gui_t(karte_t *welt) :
  buttons[19].set_text("show waiting bars");
  buttons[19].pressed = umgebung_t::show_names&1;
 
+ buttons[20].set_pos( koord(10,SLICE) );
+ buttons[20].set_typ(button_t::square_state);
+ buttons[20].set_text("sliced underground mode");
+
+ inp_underground_level.set_pos(koord(NUMBER_INP, SLICE) );
+ inp_underground_level.set_groesse( koord(50,12));
+ inp_underground_level.set_limits(welt->get_grundwasser(), 20);
+ inp_underground_level.set_value( grund_t::underground_level );
+ add_komponente(&inp_underground_level);
+ inp_underground_level.add_listener(this);
+
  // left/right for convoi tooltips
  buttons[0].set_pos( koord(10,CONVOI_TOOLTIPS) );
  buttons[0].set_typ(button_t::arrowleft);
@@ -226,8 +230,8 @@ color_gui_t::action_triggered( gui_action_creator_t *komp, value_t v)
  umgebung_t::station_coverage_show = umgebung_t::station_coverage_show==0 ? 0xFF : 0;
  } else if((buttons+16)==komp) {
  // see simwerkz.cc::wkz_show_underground_t::init
- grund_t::set_underground_mode(grund_t::underground_mode ^ grund_t::ugm_level, inp_underground_level.get_value());
- buttons[16].pressed = grund_t::underground_mode == grund_t::ugm_level;
+ grund_t::set_underground_mode(buttons[16].pressed ? grund_t::ugm_none : grund_t::ugm_all, inp_underground_level.get_value());
+ buttons[16].pressed = grund_t::underground_mode == grund_t::ugm_all;
  // calc new images
  welt->update_map();
  // renew toolbar
@@ -238,6 +242,14 @@ color_gui_t::action_triggered( gui_action_creator_t *komp, value_t v)
  umgebung_t::show_names ^= 1;
  } else if((buttons+19)==komp) {
  umgebung_t::show_names ^= 2;
+ } else if((buttons+20)==komp) {
+ // see simwerkz.cc::wkz_show_underground_t::init
+ grund_t::set_underground_mode(buttons[20].pressed ? grund_t::ugm_none : grund_t::ugm_level, inp_underground_level.get_value());
+ buttons[20].pressed = grund_t::underground_mode == grund_t::ugm_level;
+ // calc new images
+ welt->update_map();
+ // renew toolbar
+ werkzeug_t::update_toolbars(welt);
  } else if (komp == &inp_underground_level) {
  if(grund_t::underground_mode==grund_t::ugm_level) {
  grund_t::underground_level = inp_underground_level.get_value();
@@ -262,10 +274,11 @@ void color_gui_t::zeichnen(koord pos, koord gr)
  // can be changed also with keys ...
  buttons[11].pressed = umgebung_t::hide_trees;
  buttons[15].pressed = umgebung_t::station_coverage_show;
- buttons[16].pressed = grund_t::underground_mode == grund_t::ugm_level;
+ buttons[16].pressed = grund_t::underground_mode == grund_t::ugm_all;
  buttons[17].pressed = grund_t::show_grid;
  buttons[18].pressed = umgebung_t::show_names&1;
  buttons[19].pressed = (umgebung_t::show_names&2)!=0;
+ buttons[20].pressed = grund_t::underground_mode == grund_t::ugm_level;
 
  gui_frame_t::zeichnen(pos, gr);
 
diff --git a/gui/colors.h b/gui/colors.h
index dfcf525..ea3e917 100644
--- a/gui/colors.h
+++ b/gui/colors.h
@@ -13,7 +13,7 @@ class color_gui_t : public gui_frame_t, private action_listener_t
 {
 private:
  karte_t *welt;
- button_t buttons[20];
+ button_t buttons[21];
  gui_numberinput_t brightness, scrollspeed, traffic_density, inp_underground_level;
 
 public:
diff --git a/simwerkz.cc b/simwerkz.cc
index 53b60e9..549e88a 100644
--- a/simwerkz.cc
+++ b/simwerkz.cc
@@ -3670,8 +3670,16 @@ bool wkz_show_underground_t::init( karte_t *welt, spieler_t * )
  switch(default_param[0]) {
  // toggle sliced view by toolbar - height taken from extra mouse click
  case 'C':
- needs_click = true;
- ok = false;
+ if(grund_t::underground_mode==grund_t::ugm_level) {
+ grund_t::set_underground_mode( grund_t::ugm_none, 0);
+ }
+ else if(grund_t::underground_mode==grund_t::ugm_none) {
+ needs_click = true;
+ ok = false;
+ }
+ else {
+ ok = false;
+ }
  break;
  // decrease slice level
  case 'D':
@@ -3696,18 +3704,22 @@ bool wkz_show_underground_t::init( karte_t *welt, spieler_t * )
  case 'K':
  if(grund_t::underground_mode==grund_t::ugm_level) {
  // switch to normal or full-underground
- grund_t::set_underground_mode( save_underground_level==127 ? grund_t::ugm_none : grund_t::ugm_all, 0);
+ grund_t::set_underground_mode( grund_t::ugm_none, 0);
+
  }
- else {
+ else if(grund_t::underground_mode==grund_t::ugm_none) {
  grund_t::set_underground_mode( grund_t::ugm_level, zpos.z);
  }
+ else {
+ ok = false;
+ }
  break;
 
  //  switch between full underground or normal/sliced view
  case 'U':
  if (grund_t::underground_mode==grund_t::ugm_all) {
  // switch back to normal or sliced view
- grund_t::set_underground_mode( grund_t::ugm_none, 0); // save_underground_level==127 ? grund_t::ugm_none : grund_t::ugm_level, save_underground_level);
+ grund_t::set_underground_mode( save_underground_level==127 ? grund_t::ugm_none : grund_t::ugm_level, save_underground_level);
  }
  else {
  grund_t::set_underground_mode( grund_t::ugm_all, 0);
--
1.6.3.2.1299.gee46c



Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20818
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: [Patch] New underground view
« Reply #124 on: June 17, 2009, 11:22:15 PM »
Might I ask - is it possible to have an underground mode button in the menu bar? If it is, how would one go about setting that up in menuconf.tab?

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10691
  • Languages: De,EN,JP
Re: [Patch] New underground view
« Reply #125 on: June 18, 2009, 08:34:27 AM »
Looking at the sources of pak64 or simmenu.cc will tell you ...

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20818
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: [Patch] New underground view
« Reply #126 on: June 18, 2009, 10:25:05 PM »
I can't find any controls in the latest Pak64 nightly binary - has it made it there yet?

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4878
  • Languages: EN, DE, AT
Re: [Patch] New underground view
« Reply #127 on: June 19, 2009, 05:32:42 AM »
Here I described all underground tools and how to use them in menuconf.tab:

http://forum.simutrans.com/index.php?topic=1089.msg24655#msg24655

The second parameter here:
Code: [Select]
toolbar[I][J]=general_tool[34],ICON_NUMBER,KEY,U
may hold an icon number (once an icon exists). So numbers I and J, ICON_NUMBER and KEY, are up to the menuconf.tab writers

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4878
  • Languages: EN, DE, AT
Re: [Patch] New underground view
« Reply #128 on: June 19, 2009, 02:24:11 PM »
My patch for this.
http://simutrans-germany.com/files/upload/0008-slice-fixed.patch.txt

why did you remove the possibility to trigger sliced mode when in full underground mode?

Offline z9999

  • Devotees (Inactive)
  • *
  • Posts: 848
Re: [Patch] New underground view
« Reply #129 on: June 19, 2009, 05:05:21 PM »
You can change it if you don't like it.