Skip to content

Commit

Permalink
images in line tab
Browse files Browse the repository at this point in the history
git-svn-id: svn://tron.homeunix.org/simutrans/simutrans/trunk@1514 8aca7d54-2c30-db11-9de9-000461428c89
  • Loading branch information
prissi committed Dec 28, 2007
1 parent d8bb555 commit 722a9fb
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 35 deletions.
3 changes: 2 additions & 1 deletion dataobj/dingliste.cc
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,9 @@ dingliste_t::loesche_alle(spieler_t *sp, uint8 offset)
while( top>offset ) {
top --;
ding_t *dt = obj.some[top];
if(dt->is_moving()) {
if(dt->is_moving() && !(dt->gib_typ()==ding_t::fussgaenger || dt->gib_typ()==ding_t::verkehr)) {
((vehikel_t *)dt)->verlasse_feld();
assert(0);
}
else {
dt->entferne(sp);
Expand Down
80 changes: 58 additions & 22 deletions gui/components/gui_tab_panel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
#include "../../simgraph.h"
#include "../../simcolor.h"

#include "../../besch/bild_besch.h"



gui_tab_panel_t::gui_tab_panel_t()
{
Expand All @@ -20,9 +23,9 @@ gui_tab_panel_t::gui_tab_panel_t()



void gui_tab_panel_t::add_tab(gui_komponente_t *c, const char *name)
void gui_tab_panel_t::add_tab(gui_komponente_t *c, const char *name, const bild_besch_t *besch, const char *tooltip )
{
tabs.append(tab(c, name));
tabs.append(tab(c, name, besch, tooltip));
c->setze_groesse(gib_groesse()-koord(0,HEADER_VSIZE));
}

Expand All @@ -49,22 +52,26 @@ void gui_tab_panel_t::infowin_event(const event_t *ev)
translate_event(&ev2, 0, -HEADER_VSIZE);
tabs.at(active_tab).component->infowin_event(&ev2);

} else if(IS_LEFTCLICK(ev)) {
if(ev->cy > 0 && ev->cy < HEADER_VSIZE-1) {
// Reiter getroffen
int text_x = 4;
int k = 0;
for (slist_tpl<tab>::const_iterator i = tabs.begin(), end = tabs.end(); i != end; ++i, ++k) {
const char* text = translator::translate(i->title);
const int width = proportional_string_width( text );

if(text_x < ev->cx && text_x+width+8 > ev->cx) {
active_tab = k;
call_listeners((long)active_tab);
break;
}
else {
if(IS_LEFTCLICK(ev)) {
if(ev->my > 0 && ev->my < HEADER_VSIZE-1) {
// Reiter getroffen
int text_x = 4;
int k = 0;
for (slist_tpl<tab>::const_iterator i = tabs.begin(), end = tabs.end(); i != end; ++i, ++k) {
const char* text = i->title;
const int width = text ? proportional_string_width( text ) : 32;

if(text_x < ev->mx && text_x+width+8 > ev->mx) {
// either tooltip or change
active_tab = k;
call_listeners((long)active_tab);
break;
}

text_x += width + 8;
}

text_x += width + 8;
}
}
}
Expand All @@ -84,8 +91,8 @@ void gui_tab_panel_t::zeichnen(koord parent_pos)

int k = 0;
for (slist_tpl<tab>::const_iterator i = tabs.begin(), end = tabs.end(); i != end; ++i, ++k) {
const char* text = translator::translate(i->title);
const int width = proportional_string_width( text );
const char* text = i->title;
const int width = text ? proportional_string_width( text ) : 32;

if (k != active_tab) {
display_fillbox_wh_clip(text_x-4, ypos+HEADER_VSIZE-1, width+8, 1, MN_GREY4, true);
Expand All @@ -94,19 +101,48 @@ void gui_tab_panel_t::zeichnen(koord parent_pos)
display_vline_wh_clip(text_x-4, ypos+5, HEADER_VSIZE-6, MN_GREY4, true);
display_vline_wh_clip(text_x+width+3, ypos+5, HEADER_VSIZE-6, MN_GREY0, true);

display_proportional_clip(text_x, ypos+7, text, ALIGN_LEFT, COL_BLACK, true);
if(text) {
display_proportional_clip(text_x, ypos+7, text, ALIGN_LEFT, COL_WHITE, true);
}
else {
display_color_img( i->img->gib_nummer(), text_x - i->img->get_pic()->x + 16 - (i->img->get_pic()->w/2), ypos - i->img->get_pic()->y + 10 - (i->img->get_pic()->h/2), 0, false, true);
}
} else {
display_fillbox_wh_clip(text_x-3, ypos+3, width+5, 1, MN_GREY4, true);

display_vline_wh_clip(text_x-4, ypos+4, 13, MN_GREY4, true);
display_vline_wh_clip(text_x+width+3, ypos+4, 13, MN_GREY0, true);

display_proportional_clip(text_x, ypos+7, text, ALIGN_LEFT, COL_BLACK, true);

if(text) {
display_proportional_clip(text_x, ypos+7, text, ALIGN_LEFT, COL_BLACK, true);
}
else {
display_color_img( i->img->gib_nummer(), text_x - i->img->get_pic()->x + 16 - (i->img->get_pic()->w/2), ypos - i->img->get_pic()->y + 10 - (i->img->get_pic()->h/2), 0, false, true);
}
i->component->zeichnen(koord(xpos + 0, ypos + HEADER_VSIZE));
}

text_x += width + 8;
}
display_fillbox_wh_clip(text_x-4, ypos+HEADER_VSIZE-1, groesse.x-(text_x-xpos)+4, 1, MN_GREY4, true);

int my = gib_maus_y()-parent_pos.y-6;
if(my>=0 && my < HEADER_VSIZE-1) {
// Reiter getroffen?
int mx = gib_maus_x()-parent_pos.x-11;
int text_x = 4;
int k = 0;
for (slist_tpl<tab>::const_iterator i = tabs.begin(), end = tabs.end(); i != end; ++i, ++k) {
const char* text = i->title;
const int width = text ? proportional_string_width( text ) : 32;

if(text_x < mx && text_x+width+8 > mx) {
// tooltip or change
win_set_tooltip(gib_maus_x() + 16, gib_maus_y() - 16, i->tooltip );
break;
}

text_x += width + 8;
}
}
}
11 changes: 8 additions & 3 deletions gui/components/gui_tab_panel.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#define gui_tab_panel_h

#include "../../ifc/gui_action_creator.h"
#include "../../simimg.h"

class bild_besch_t;

/**
* Eine Klasse für Registerkartenartige Aufteilung von gui_komponente_t
Expand All @@ -22,7 +25,7 @@ class gui_tab_panel_t : public gui_komponente_action_creator_t
* @param name der Name der Registerkarte für die Komponente
* @author Hj. Malthaner
*/
void add_tab(gui_komponente_t *c, const char *name);
void add_tab(gui_komponente_t *c, const char *name, const bild_besch_t *b=NULL, const char *tooltip=NULL );

/**
* Gibt die aktuell angezeigte Komponente zurück.
Expand Down Expand Up @@ -55,10 +58,12 @@ class gui_tab_panel_t : public gui_komponente_action_creator_t
private:
struct tab
{
tab(gui_komponente_t* c, const char* t) : component(c), title(t) {}
tab(gui_komponente_t* c, const char *name, const bild_besch_t *b, const char *tool) : component(c), title(name), img(b), tooltip(tool) {}

gui_komponente_t* component;
const char* title;
const char *title;
const bild_besch_t *img;
const char *tooltip;
};

slist_tpl<tab> tabs;
Expand Down
6 changes: 3 additions & 3 deletions gui/depot_frame.cc
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,15 @@ DBG_DEBUG("depot_frame_t::depot_frame_t()","get_max_convoi_length()=%i",depot->g
scrolly_pas.set_read_only(false);

// always add
tabs.add_tab(&scrolly_pas, depot->gib_passenger_name());
tabs.add_tab(&scrolly_pas, translator::translate( depot->gib_passenger_name() ) );

cont_loks.add_komponente(&loks);
scrolly_loks.set_show_scroll_x(false);
scrolly_loks.set_size_corner(false);
scrolly_loks.set_read_only(false);
// add, if waggons are there ...
if (!loks_vec.empty() || !waggons_vec.empty()) {
tabs.add_tab(&scrolly_loks, depot->gib_zieher_name());
tabs.add_tab(&scrolly_loks, translator::translate( depot->gib_zieher_name() ) );
}

cont_waggons.add_komponente(&waggons);
Expand All @@ -206,7 +206,7 @@ DBG_DEBUG("depot_frame_t::depot_frame_t()","get_max_convoi_length()=%i",depot->g
scrolly_waggons.set_read_only(false);
// only add, if there are waggons
if (!waggons_vec.empty()) {
tabs.add_tab(&scrolly_waggons, depot->gib_haenger_name());
tabs.add_tab(&scrolly_waggons, translator::translate( ( depot->gib_haenger_name() ) );
}

pas.set_player_nr(depot->get_player_nr());
Expand Down
13 changes: 7 additions & 6 deletions gui/schedule_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "../simworld.h"
#include "../simevent.h"
#include "../simgraph.h"
#include "../simskin.h"
#include "../simplay.h"
#include "../simconvoi.h"
#include "../simvehikel.h"
Expand Down Expand Up @@ -89,12 +90,12 @@ schedule_list_gui_t::schedule_list_gui_t(spieler_t* sp_) :
tabs.setze_pos(koord(11,5));
tabs.setze_groesse(koord(LINE_NAME_COLUMN_WIDTH-22, SCL_HEIGHT));
tabs.add_tab(&scl, translator::translate("All"));
tabs.add_tab(&scl, translator::translate("Train"));
tabs.add_tab(&scl, translator::translate("Monorail"));
tabs.add_tab(&scl, translator::translate("Tram"));
tabs.add_tab(&scl, translator::translate("Truck"));
tabs.add_tab(&scl, translator::translate("Ship"));
tabs.add_tab(&scl, translator::translate("Air"));
tabs.add_tab(&scl, NULL, skinverwaltung_t::zughaltsymbol->gib_bild(0), translator::translate("Train"));
tabs.add_tab(&scl, NULL, skinverwaltung_t::monorailhaltsymbol->gib_bild(0), translator::translate("Monorail"));
tabs.add_tab(&scl, NULL, skinverwaltung_t::tramhaltsymbol->gib_bild(0), translator::translate("Tram"));
tabs.add_tab(&scl, NULL, skinverwaltung_t::autohaltsymbol->gib_bild(0), translator::translate("Truck"));
tabs.add_tab(&scl, NULL, skinverwaltung_t::schiffshaltsymbol->gib_bild(0), translator::translate("Ship"));
tabs.add_tab(&scl, NULL, skinverwaltung_t::airhaltsymbol->gib_bild(0), translator::translate("Air"));
tabs.add_listener(this);
add_komponente(&tabs);

Expand Down
2 changes: 2 additions & 0 deletions simskin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const skin_besch_t* skinverwaltung_t::schiffshaltsymbol = NULL;
const skin_besch_t* skinverwaltung_t::airhaltsymbol = NULL;
const skin_besch_t* skinverwaltung_t::monorailhaltsymbol = NULL;
const skin_besch_t* skinverwaltung_t::bushaltsymbol = NULL;
const skin_besch_t* skinverwaltung_t::tramhaltsymbol = NULL;

const skin_besch_t* skinverwaltung_t::fragezeiger = NULL;
const skin_besch_t* skinverwaltung_t::signalzeiger = NULL;
Expand Down Expand Up @@ -100,6 +101,7 @@ static spezial_obj_tpl<skin_besch_t> symbol_objekte[] = {
{ &skinverwaltung_t::bushaltsymbol, "BusStop" },
{ &skinverwaltung_t::airhaltsymbol, "AirStop" },
{ &skinverwaltung_t::monorailhaltsymbol, "MonorailStop" },
{ &skinverwaltung_t::tramhaltsymbol, "TramStop" },
{ &skinverwaltung_t::electricity, "Electricity" },
{ &skinverwaltung_t::intown, "InTown" },
{ &skinverwaltung_t::passagiere, "Passagiere" },
Expand Down
1 change: 1 addition & 0 deletions simskin.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class skinverwaltung_t {
static const skin_besch_t *airhaltsymbol;
static const skin_besch_t *monorailhaltsymbol;
static const skin_besch_t *bushaltsymbol;
static const skin_besch_t *tramhaltsymbol;

static const skin_besch_t *fragezeiger;
static const skin_besch_t *signalzeiger;
Expand Down
1 change: 1 addition & 0 deletions simutrans/history.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
CHANGE: allow for offsets in the texture files => pak192 grounds possible
CHANGE: new convoi filter for stuck convois 'clf_chk_stucked'
FIX: could delete crossings under certain circumstances
CHANGE: images in line tab, translation now tooltip


Release of 99.17 (r1502)
Expand Down

0 comments on commit 722a9fb

Please sign in to comment.