Skip to content

Commit

Permalink
CODE: gui code translation, do not use koord anymore in gui (kierongr…
Browse files Browse the repository at this point in the history
…een/dwachs)

git-svn-id: svn://tron.homeunix.org/simutrans/simutrans/trunk@6911 8aca7d54-2c30-db11-9de9-000461428c89
  • Loading branch information
Dwachs committed Nov 20, 2013
1 parent c453368 commit 50e0f55
Show file tree
Hide file tree
Showing 185 changed files with 2,464 additions and 2,434 deletions.
6 changes: 3 additions & 3 deletions bauer/fabrikbauer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ void fabrikbauer_t::verteile_tourist(karte_t* welt, int max_number)

}
// update an open map
reliefkarte_t::get_karte()->calc_map_groesse();
reliefkarte_t::get_karte()->calc_map_size();
}

class RelativeDistanceOrdering
Expand Down Expand Up @@ -644,7 +644,7 @@ int fabrikbauer_t::baue_hierarchie(koord3d* parent, const fabrik_besch_t* info,
DBG_MESSAGE("fabrikbauer_t::baue_hierarchie()","update karte");

// update the map if needed
reliefkarte_t::get_karte()->calc_map_groesse();
reliefkarte_t::get_karte()->calc_map_size();

INT_CHECK( "fabrikbauer 730" );

Expand Down Expand Up @@ -992,7 +992,7 @@ int fabrikbauer_t::increase_industry_density( karte_t *welt, bool tell_me )
nr += baue_hierarchie(NULL, fab, -1 /*random prodbase */, rotation, &pos, welt->get_spieler(1), 1 );
if(nr>0) {
fabrik_t *our_fab = fabrik_t::get_fab( pos.get_2d() );
reliefkarte_t::get_karte()->calc_map_groesse();
reliefkarte_t::get_karte()->calc_map_size();
// tell the player
if(tell_me) {
stadt_t *s = welt->suche_naechste_stadt( pos.get_2d() );
Expand Down
2 changes: 1 addition & 1 deletion dataobj/environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ bool env_t::mute_sound = false;
bool env_t::mute_midi = false;
bool env_t::shuffle_midi = true;
sint16 env_t::window_snap_distance = 8;
koord env_t::iconsize( 32, 32 );
scr_size env_t::iconsize( 32, 32 );
uint8 env_t::chat_window_transparency = 75;
bool env_t::hide_rail_return_ticket = true;

Expand Down
4 changes: 2 additions & 2 deletions dataobj/environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "../simtypes.h"
#include "../simconst.h"
#include "settings.h"
#include "koord.h"
#include "../display/scr_coord.h"

#include "../tpl/vector_tpl.h"
#include "../utils/plainstring.h"
Expand Down Expand Up @@ -174,7 +174,7 @@ class env_t

static sint16 window_snap_distance;

static koord iconsize;
static scr_size iconsize;

/// customize your tooltips
static bool show_tooltips;
Expand Down
8 changes: 4 additions & 4 deletions dataobj/gameinfo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ gameinfo_t::gameinfo_t(karte_t *welt) :
file_name(""),
pak_name("")
{
groesse_x = welt->get_size().x;
groesse_y = welt->get_size().y;
size_x = welt->get_size().x;
size_y = welt->get_size().y;

// create a minimap

Expand Down Expand Up @@ -126,8 +126,8 @@ void gameinfo_t::rdwr(loadsave_t *file)
{
xml_tag_t e( file, "gameinfo_t" );

file->rdwr_long( groesse_x );
file->rdwr_long( groesse_y );
file->rdwr_long( size_x );
file->rdwr_long( size_y );
for( int y=0; y<MINIMAP_SIZE; y++ ) {
for( int x=0; x<MINIMAP_SIZE; x++ ) {
file->rdwr_byte( map.at(x,y) );
Expand Down
6 changes: 3 additions & 3 deletions dataobj/gameinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class loadsave_t;
class gameinfo_t
{
private:
sint32 groesse_x, groesse_y;
sint32 size_x, size_y;
array2d_tpl<uint8> map;

sint32 industries;
Expand Down Expand Up @@ -56,8 +56,8 @@ class gameinfo_t

void rdwr( loadsave_t *file );

sint32 get_groesse_x() const {return groesse_x;}
sint32 get_groesse_y() const {return groesse_y;}
sint32 get_size_x() const {return size_x;}
sint32 get_size_y() const {return size_y;}
const array2d_tpl<uint8> *get_map() const { return &map; }

sint32 get_industries() const {return industries;}
Expand Down
13 changes: 4 additions & 9 deletions dataobj/koord.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
uint32 koord::locality_factor = 10000;


const scr_coord scr_coord::invalid(-1, -1);

const scr_size scr_size::invalid(-1, -1);

const koord koord::invalid(-1, -1);
const koord koord::nord( 0, -1);
const koord koord::ost( 1, 0);
Expand Down Expand Up @@ -135,15 +139,6 @@ const koord koord::from_hang[] = {
koord( 0, 0) // 80:
};

/**
* type conversion from koord to the new scr_coord
* @author Max Kielland
*/
koord::operator scr_coord()
{
return scr_coord( x, y );
}


void koord::rdwr(loadsave_t *file)
{
Expand Down
6 changes: 0 additions & 6 deletions dataobj/koord.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ class koord
return *this;
}

/**
* type conversion from koord to the new scr_coord
* @author Max Kielland
*/
operator scr_coord();

void rotate90( sint16 y_size )
{
if( (x&y)<0 ) {
Expand Down
116 changes: 101 additions & 15 deletions display/scr_coord.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

#include <assert.h>
#include "../dataobj/koord.h"
#include "../dataobj/loadsave.h"
#include "../simtypes.h"



// Screen coordinate type
typedef sint16 scr_coord_val;

Expand All @@ -23,25 +23,28 @@ class scr_coord
// Constructors
scr_coord( ) { x = y = 0; }
scr_coord( scr_coord_val x_, scr_coord_val y_ ) { x = x_; y=y_; }
scr_coord( const koord pos_par) { x = pos_par.x; y = pos_par.y; }

// temporary until koord has been replaced by scr_coord.
operator koord() const { return koord(x,y); }

bool operator ==(const scr_coord& other) const { return ((x-other.x) | (y-other.y)) == 0; }
bool operator !=(const scr_coord& other) const { return !(other == *this ); }
const scr_coord operator +(const scr_coord& other ) const { return scr_coord( other.x + x, other.y + y); }
const scr_coord operator -(const scr_coord& other ) const { return scr_coord( x - other.x, y - other.y ); }

void rdwr(loadsave_t *file)
{
xml_tag_t k( file, "koord" );
file->rdwr_short(x);
file->rdwr_short(y);
}

const scr_coord& operator +=(const scr_coord& other ) {
x += other.x;
y += other.y;
return *this;
}

const scr_coord& operator -=(const scr_coord& other ) {
x += other.x;
y += other.y;
x -= other.x;
y -= other.y;
return *this;
}

Expand All @@ -54,9 +57,47 @@ class scr_coord
x = x_par;
y = y_par;
}

inline void clip_lefttop( scr_coord scr_lefttop )
{
if (x < scr_lefttop.x) {
x = scr_lefttop.x;
}
if (y < scr_lefttop.y) {
y = scr_lefttop.y;
}
}

inline void clip_rightbottom( scr_coord scr_rightbottom )
{
if (x > scr_rightbottom.x) {
x = scr_rightbottom.x;
}
if (y > scr_rightbottom.y) {
y = scr_rightbottom.y;
}
}

static const scr_coord invalid;

private:
// conversions to/from koord not allowed anymore
scr_coord( const koord pos_par) { x = pos_par.x; y = pos_par.y; }
operator koord() const { return koord(x,y); }
};


static inline scr_coord operator * (const scr_coord &k, const sint16 m)
{
return scr_coord(k.x * m, k.y * m);
}


static inline scr_coord operator / (const scr_coord &k, const sint16 m)
{
return scr_coord(k.x / m, k.y / m);
}


// Very simple scr_size struct.
class scr_size
Expand All @@ -70,13 +111,41 @@ class scr_size
scr_size( scr_coord_val w_par, scr_coord_val h_par) { w = w_par; h = h_par; }
scr_size( const scr_size& size ) { w = size.w; h=size.h; }

operator koord() const { return koord(w,h); }
operator scr_coord() const { return scr_coord(w,h); }

bool operator ==(const scr_size& other) const { return ((w-other.w) | (h-other.h)) == 0; }
bool operator !=(const scr_size& other) const { return !(other == *this ); }
const scr_size operator +(const scr_size& other ) const { return scr_size( other.w + w, other.h + h); }
const scr_size operator -(const scr_size& other ) const { return scr_size( w - other.w, h - other.h ); }
const scr_size operator +(const scr_coord& other ) const { return scr_size( other.x + w, other.y + h); }
const scr_size operator -(const scr_coord& other ) const { return scr_size( w - other.x, h - other.y ); }

void rdwr(loadsave_t *file)
{
xml_tag_t k( file, "koord" );
file->rdwr_short(w);
file->rdwr_short(h);
}

inline void clip_lefttop( scr_coord scr_lefttop )
{
if (w < scr_lefttop.x) {
w = scr_lefttop.x;
}
if (h < scr_lefttop.y) {
h = scr_lefttop.y;
}
}

inline void clip_rightbottom( scr_coord scr_rightbottom )
{
if (w > scr_rightbottom.x) {
w = scr_rightbottom.x;
}
if (h > scr_rightbottom.y) {
h = scr_rightbottom.y;
}
}

const scr_size& operator +=(const scr_size& other ) {
w += other.w;
Expand All @@ -90,6 +159,23 @@ class scr_size
return *this;
}

const scr_size& operator +=(const scr_coord& other ) {
w += other.x;
h += other.y;
return *this;
}

const scr_size& operator -=(const scr_coord& other ) {
w += other.x;
h += other.y;
return *this;
}

static const scr_size invalid;

private:
// conversions to/from koord not allowed anymore
operator koord() const { return koord(w,h); }
};


Expand All @@ -114,14 +200,14 @@ class scr_rect
scr_rect() { set(0,0,0,0); }
scr_rect( const scr_coord& pt ) { set( pt.x, pt.y, 0, 0 ); }
scr_rect( const scr_coord& pt, scr_coord_val w, scr_coord_val h ) { set( pt.x, pt.y, w, h ); }
scr_rect( const scr_coord& pt, const scr_size& sz ) { set( pt.x, pt.y, sz.w, sz.h ); }
scr_rect( scr_coord_val x, scr_coord_val y, scr_coord_val w, scr_coord_val h ) { set( x, y, w, h ); }
scr_rect( scr_size size ) { w = size.w; h=size.h; }
scr_rect( const scr_coord& point1, const scr_coord& point2 ) { set( point1.x, point1.y, point2.x-point1.x, point2.y-point1.y ); }

// Type cast operators
operator scr_size() const { return scr_size (w,h); }
operator scr_coord() const { return scr_coord(x,y); }
operator koord() const { return koord(w,h); }

// Unary operators
const scr_rect operator +(const scr_coord& other ) const { scr_rect rect(x + other.x, y + other.y, w, h ); return rect; }
Expand All @@ -130,12 +216,6 @@ class scr_rect
const scr_rect operator +(const scr_size& sz ) const { return scr_rect(x,y, w+sz.w, h+sz.h ); }
const scr_rect operator -(const scr_size& sz ) const { return scr_rect(x,y, w-sz.w, h-sz.h ); }

// for now still accepted, will be removed
// when we convert all relevant koord to scr_coord.
scr_rect( const koord& pt ) { set( pt.x, pt.y, 0, 0 ); }
scr_rect( const koord& pt, const koord& size ) { set( pt.x, pt.y, size.x, size.y ); }
scr_rect( const koord& pt, scr_coord_val w, scr_coord_val h ) { set( pt.x, pt.y, w, h ); }

// Validation functions
bool is_empty() const { return (w|h) == 0; }
bool is_valid() const { return !is_empty(); }
Expand Down Expand Up @@ -275,5 +355,11 @@ class scr_rect
bool operator !=(const scr_rect& rect_par) const {
return !(rect_par==*this);
}
private:
// conversions to/from koord not allowed anymore
scr_rect( const koord& pt ) { set( pt.x, pt.y, 0, 0 ); }
scr_rect( const koord& pt, const koord& size ) { set( pt.x, pt.y, size.x, size.y ); }
scr_rect( const koord& pt, scr_coord_val w, scr_coord_val h ) { set( pt.x, pt.y, w, h ); }
operator koord() const { return koord(w,h); }
};
#endif
2 changes: 1 addition & 1 deletion display/simview.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void karte_ansicht_t::display(bool force_dirty)
uint32 rs = get_random_seed();
const sint16 disp_width = display_get_width();
const sint16 disp_real_height = display_get_height();
const sint16 menu_height = env_t::iconsize.y;
const sint16 menu_height = env_t::iconsize.h;
const sint16 IMG_SIZE = get_tile_raster_width();

const sint16 disp_height = display_get_height() - 16 - (!ticker::empty() ? 16 : 0);
Expand Down
Loading

0 comments on commit 50e0f55

Please sign in to comment.