Skip to content

Commit

Permalink
Senate tooltip add. Remove fish from granary store.
Browse files Browse the repository at this point in the history
  • Loading branch information
sleepstranger committed Jul 2, 2013
1 parent 88c372a commit fd4bf72
Show file tree
Hide file tree
Showing 17 changed files with 217 additions and 64 deletions.
Binary file added docs/CIII_EmpireCatalog_PharaohAah.pdf
Binary file not shown.
6 changes: 6 additions & 0 deletions oc3_city.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "oc3_gettext.hpp"
#include "oc3_build_options.hpp"
#include "oc3_house.hpp"
#include "oc3_tilemap.hpp"

#include <set>

Expand Down Expand Up @@ -648,4 +649,9 @@ CityPtr City::create()
ret->drop();

return ret;
}

LandOverlayPtr City::getOverlay( const TilePos& pos ) const
{
return _d->tilemap.at( pos ).getTerrain().getOverlay();
}
11 changes: 6 additions & 5 deletions oc3_city.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@
// Copyright 2012-2013 Gregoire Athanase, gathanase@gmail.com


#ifndef CITY_HPP
#define CITY_HPP
#ifndef __OPENCAESAR3_CITY_H_INCLUDED__
#define __OPENCAESAR3_CITY_H_INCLUDED__

#include "oc3_tilemap.hpp"
#include "oc3_walker.hpp"
#include "oc3_enums.hpp"
#include "oc3_serializer.hpp"
Expand Down Expand Up @@ -95,6 +94,8 @@ class City : public Serializable, public ReferenceCounted

const DateTime& getDate() const;
void setDate( const DateTime& time );

LandOverlayPtr getOverlay( const TilePos& pos ) const;

oc3_signals public:
Signal1<int>& onPopulationChanged();
Expand Down Expand Up @@ -136,12 +137,12 @@ class CityHelper
template< class T >
SmartPtr< T > getBuilding( const TilePos& pos )
{
LandOverlayPtr overlay = _city->getTilemap().at( pos ).getTerrain().getOverlay();
LandOverlayPtr overlay = _city->getOverlay( pos );
return overlay.as< T >();
}

protected:
CityPtr _city;
};

#endif
#endif //__OPENCAESAR3_CITY_H_INCLUDED__
3 changes: 2 additions & 1 deletion oc3_granary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class GranaryGoodStore : public SimpleGoodStore
setOrder( (GoodType)type, GoodOrders::accept );
}

setOrder( G_FISH, GoodOrders::none );
setMaxQty( GranaryGoodStore::maxCapacity );
}

Expand All @@ -52,7 +53,7 @@ class Granary::Impl

Granary::Granary() : WorkingBuilding( B_GRANARY, Size(3) ), _d( new Impl )
{
setMaxWorkers(5);
setMaxWorkers(6);
setWorkers(0);

setPicture( Picture::load( ResourceGroup::commerce, 140));
Expand Down
1 change: 0 additions & 1 deletion oc3_gui_info_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,6 @@ void GuiInfoGranary::paint()

int _col2PaintY = _paintY;
drawGood(G_WHEAT, 0, _paintY);
drawGood(G_FISH, 0, _paintY);
drawGood(G_MEAT, 0, _paintY);
drawGood(G_FRUIT, 1, _col2PaintY);
drawGood(G_VEGETABLE, 1, _col2PaintY);
Expand Down
9 changes: 6 additions & 3 deletions oc3_screen_game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "oc3_alarm_event_holder.hpp"
#include "oc3_tilemap_renderer.hpp"
#include "oc3_scenario.hpp"
#include "oc3_senate_popup_info.hpp"

class ScreenGame::Impl
{
Expand Down Expand Up @@ -123,6 +124,8 @@ void ScreenGame::initialize( GfxEngine& engine, GuiEnv& gui )
// here move camera to start position of map
getMapArea().setCenterIJ( _d->scenario->getCity()->getCameraPos() );

new SenatePopupInfo( _d->gui->getRootWidget(), _d->mapRenderer );

//connect elements
CityPtr city = _d->scenario->getCity();
CONNECT( _d->topMenu, onSave(), _d.data(), Impl::showSaveDialog );
Expand Down Expand Up @@ -282,12 +285,12 @@ int ScreenGame::getResult() const

void ScreenGame::Impl::resolveCreateConstruction( int type )
{
mapRenderer.setChangeCommand( TilemapBuildCommand::create( BuildingType( type ) ) );
mapRenderer.setMode( TilemapBuildCommand::create( BuildingType( type ) ) );
}

void ScreenGame::Impl::resolveRemoveTool()
{
mapRenderer.setChangeCommand( TilemapRemoveCommand::create() );
mapRenderer.setMode( TilemapRemoveCommand::create() );
}

void ScreenGame::Impl::showTileInfo( const Tile& tile )
Expand All @@ -309,7 +312,7 @@ void ScreenGame::resolveExitGame()

void ScreenGame::Impl::resolveSelectOverlayView( int type )
{
mapRenderer.setChangeCommand( TilemapOverlayCommand::create( OverlayType( type ) ) );
mapRenderer.setMode( TilemapOverlayCommand::create( OverlayType( type ) ) );
}

void ScreenGame::Impl::showAdvisorsWindow()
Expand Down
2 changes: 1 addition & 1 deletion oc3_senate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
// govt 9 - advanced senate
// govt 5 ~ 8 - senate flags

Senate::Senate() : ServiceBuilding(S_SENATE, B_SENATE, Size(5) )
Senate::Senate() : ServiceBuilding( S_SENATE, B_SENATE, Size(5) )
{
setPicture( Picture::load( ResourceGroup::govt, 4) );
}
Expand Down
96 changes: 96 additions & 0 deletions oc3_senate_popup_info.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// This file is part of openCaesar3.
//
// openCaesar3 is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// openCaesar3 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with openCaesar3. If not, see <http://www.gnu.org/licenses/>.

#include "oc3_senate_popup_info.hpp"
#include "oc3_tilemap_renderer.hpp"
#include "oc3_senate.hpp"
#include "oc3_gui_paneling.hpp"
#include "oc3_gettext.hpp"
#include "oc3_guienv.hpp"
#include "oc3_tile.hpp"
#include "oc3_gfx_engine.hpp"
#include "oc3_stringhelper.hpp"
#include "oc3_color.hpp"
#include "oc3_time.hpp"

class SenatePopupInfo::Impl
{
public:
Point startPos;
Point ratingStartPos;
Point offset;
Font font;
TilemapRenderer* mapRenderer;
PictureRef background;
int lastUpdateTime;

void updateRatings()
{
lastUpdateTime = DateTime::getElapsedTime();

background->fill( 0xffffffff, Rect( ratingStartPos.getX(), ratingStartPos.getY(), background->getWidth()-2, background->getHeight()-2 ) );
font.draw( *background, StringHelper::format( 0xff, "%d %%", 0 ), ratingStartPos );
font.draw( *background, StringHelper::format( 0xff, "%d", 0 ), ratingStartPos + offset );
font.draw( *background, StringHelper::format( 0xff, "%d", 0 ), ratingStartPos + offset * 2 );
font.draw( *background, StringHelper::format( 0xff, "%d", 0 ), ratingStartPos + offset * 3 );
font.draw( *background, StringHelper::format( 0xff, "%d", 0 ), ratingStartPos + offset * 4 );
}
};

SenatePopupInfo::SenatePopupInfo( Widget* parent, TilemapRenderer& mapRenderer ) :
Widget( parent, -1, Rect( -1, -1, 0, 0 )), _d( new Impl )
{
_d->mapRenderer = &mapRenderer;
_d->startPos = Point( 6, 6 );
_d->ratingStartPos = Point( 186, 6 );
_d->offset = Point( 0, 14 );
_d->lastUpdateTime = 0;
_d->background.reset( Picture::create( Size( 240, 80 ) ) );

_d->background->fill( 0xff000000, Rect( Point( 0, 0 ), _d->background->getSize() ) );
_d->background->fill( 0xffffffff, Rect( Point( 1, 1 ), _d->background->getSize() - Size( 2, 2 ) ) );

_d->font = Font::create( FONT_1 );

_d->font.draw( *_d->background, _("##senatepp_unemployment##"), _d->startPos );
_d->font.draw( *_d->background, _("##senatepp_clt_rating##"), _d->startPos + _d->offset );
_d->font.draw( *_d->background, _("##senatepp_prsp_rating##"), _d->startPos + _d->offset * 2 );
_d->font.draw( *_d->background, _("##senatepp_peace_rating##"), _d->startPos + _d->offset * 3 );
_d->font.draw( *_d->background, _("##senatepp_favour_rating##"), _d->startPos + _d->offset * 4 );

_d->updateRatings();
}

void SenatePopupInfo::draw( GfxEngine& painter )
{
Point cursorPos = getEnvironment()->getCursorPos();

Tile* tile = _d->mapRenderer->getTile( cursorPos, false );

if( tile )
{
SmartPtr< Senate > senate = tile->getTerrain().getOverlay().as< Senate >();

if( senate.isValid() )
{
if( DateTime::getElapsedTime() - _d->lastUpdateTime > 2000 )
{
_d->updateRatings();
}

painter.drawPicture( *_d->background, cursorPos );
}
}
}
35 changes: 35 additions & 0 deletions oc3_senate_popup_info.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// This file is part of openCaesar3.
//
// openCaesar3 is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// openCaesar3 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with openCaesar3. If not, see <http://www.gnu.org/licenses/>.

#ifndef __OPENCAESAR3_SENATE_POPUP_INFO_H_INCLUDED__
#define __OPENCAESAR3_SENATE_POPUP_INFO_H_INCLUDED__

#include "oc3_widget.hpp"
#include "oc3_scopedptr.hpp"

class TilemapRenderer;

class SenatePopupInfo : public Widget
{
public:
SenatePopupInfo( Widget* parent, TilemapRenderer& mapRenderer );

void draw( GfxEngine& painter );
private:
class Impl;
ScopedPtr< Impl > _d;
};

#endif
2 changes: 1 addition & 1 deletion oc3_service_building.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ServiceBuilding : public WorkingBuilding
virtual ~ServiceBuilding();

ServiceType getService() const;
void timeStep(const unsigned long time);
virtual void timeStep(const unsigned long time);
virtual void destroy(); // handles the walkers

int getServiceRange() const; // max distance from building to road for road to propose the service
Expand Down
1 change: 1 addition & 0 deletions oc3_size.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Size : Vector2<int>
bool operator==(const Size& other) const{ return (x == other.x) && ( y == other.y ); }
bool operator!=(const Size& other) const{ return (x != other.x ) || ( y != other.y ); }
Size& operator+=(const Size& other) { x += other.x; y += other.y; return *this; }
Size operator-(const Size& other) { return Size( x - other.x, y - other.y ); }
Size& operator=(const Vector2<int>& s ) { x = s.getX(), y = s.getY(); return *this; }
};

Expand Down
1 change: 1 addition & 0 deletions oc3_special_orders_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class OrderGoodWidget : public Label
{
GoodOrders::Order rule = _storageBuilding->getGoodStore().getOrder( _type );
std::string ruleName[] = { _("##accept##"), _("##reject##"), _("##deliver##"), _("##none##") };
_btnChangeRule->setFont( Font::create( rule == GoodOrders::reject ? FONT_1_RED : FONT_1_WHITE ) );
_btnChangeRule->setText( ruleName[ rule ] );
}

Expand Down
18 changes: 9 additions & 9 deletions oc3_tilemap_area.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
class TilemapArea::Impl
{
public:
Point centerMapXZ; //center of the view (in tiles)
Size viewSize; // width of the view (in tiles) nb_tilesX = 1+2*_view_width
// height of the view (in tiles) nb_tilesY = 1+2*_view_height

Expand All @@ -42,8 +43,7 @@ TilemapArea::TilemapArea() : _d( new Impl )
_d->viewSize = Size( 0 );
_center_i = 0;
_center_j = 0;
_center_x = 0;
_center_z = 0;
_d->centerMapXZ = Point( 0, 0 );
}

TilemapArea::~TilemapArea()
Expand Down Expand Up @@ -79,17 +79,16 @@ void TilemapArea::setCenterIJ(const TilePos& pos )

void TilemapArea::setCenterXZ(const int x, const int z)
{
if (_center_x != x || _center_z != z)
if( _d->centerMapXZ.getX() != x || _d->centerMapXZ.getY() != z)
{
_d->coordinates.clear();
}

_center_x = x;
_center_z = z;
_d->centerMapXZ = Point( x, z );
}

int TilemapArea::getCenterX() const { return _center_x; }
int TilemapArea::getCenterZ() const { return _center_z; }
int TilemapArea::getCenterX() const { return _d->centerMapXZ.getX(); }
int TilemapArea::getCenterZ() const { return _d->centerMapXZ.getY(); }
int TilemapArea::getCenterI() const { return _center_i; }
int TilemapArea::getCenterJ() const { return _center_j; }

Expand Down Expand Up @@ -119,8 +118,9 @@ const std::vector< TilePos >& TilemapArea::getTiles()
if( _d->coordinates.empty() )
{
int zm = _map_size + 1;
int cx = _center_x;
int cz = _center_z;
int cx = _d->centerMapXZ.getX();
int cz = _d->centerMapXZ.getY();

Size sizeT = _d->viewSize; // size x

for (int z = cz + sizeT.getHeight(); z>=cz - sizeT.getHeight(); --z)
Expand Down
5 changes: 1 addition & 4 deletions oc3_tilemap_area.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,14 @@ class TilemapArea
int getCenterI() const;
int getCenterJ() const;

private:

private:
void setCenterXZ(const int x, const int z);

int _center_i;
int _center_j;

Tilemap* _tilemap; // tile map to display
int _map_size; // size of the map (in tiles)
int _center_x; // horizontal center of the view (in tiles)
int _center_z; // vertical center of the view (in tiles)

class Impl;
ScopedPtr< Impl > _d;
Expand Down
Loading

0 comments on commit fd4bf72

Please sign in to comment.