News:

Simutrans Wiki Manual
The official on-line manual for Simutrans. Read and contribute.

[Patch] New underground view

Started by Dwachs, December 27, 2008, 03:08:37 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

VS

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...

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

prissi

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.


z9999

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.

Dwachs

Quote from: z9999 on May 14, 2009, 03:49:40 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?
Parsley, sage, rosemary, and maggikraut.

Dwachs

Parsley, sage, rosemary, and maggikraut.

Dwachs

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.

# 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
Parsley, sage, rosemary, and maggikraut.

prissi

I will have a look at it today. Not sure, if the one tool idea survives though.

Dwachs

I re-uploaded the patch.

The patch needs several strings to be translated:

two error messages:

Terraforming not possible\nhere in underground view
Cannot built this station/building\nin underground mode here.

tooltips:

sliced underground mode
decrease underground view level
increase underground view level
Parsley, sage, rosemary, and maggikraut.

prissi

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).

jamespetts

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 :-)
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Isaac Eiland-Hall

Does this imply that we will be able to tunnel under the ocean?

Dwachs

#116
Quote from: Isaac.Eiland-Hall on June 16, 2009, 04:44:51 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.

Quote from: jamespetts on June 16, 2009, 12:22:31 AM
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.

Quote from: prissi 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).
I corrected this, however a nice way to impose restrictions on the slice level is still missing...
Parsley, sage, rosemary, and maggikraut.

jamespetts

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?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Dwachs

Parsley, sage, rosemary, and maggikraut.

z9999

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.

prissi

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.)

z9999

#121
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.

Dwachs

Yes you are right, this has to be modified for true toggling. I will look into that tonight.
Parsley, sage, rosemary, and maggikraut.

z9999

My patch for this.
http://simutrans-germany.com/files/upload/0008-slice-fixed.patch.txt


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




jamespetts

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?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

prissi

Looking at the sources of pak64 or simmenu.cc will tell you ...

jamespetts

I can't find any controls in the latest Pak64 nightly binary - has it made it there yet?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Dwachs

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:

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
Parsley, sage, rosemary, and maggikraut.

Dwachs

Parsley, sage, rosemary, and maggikraut.

z9999

You can change it if you don't like it.