mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
* PreGame interface gets now redrawn every frame.
* Changed PreGame event handling and update/draw order. * Changed mouse cursor drawing in PreGame * Fixed linux bug where main menu WOG animation gets played only once, windows/linux video handling is now more similar * Minor code improvements
This commit is contained in:
@@ -76,6 +76,11 @@ void CCursorHandler::draw2()
|
||||
//blitAt(help,x,y);
|
||||
}
|
||||
|
||||
void CCursorHandler::draw(SDL_Surface *to)
|
||||
{
|
||||
CSDL_Ext::blitSurface(cursors[mode]->ourImages[number].bitmap, 0, to, &genRect(40, 40, xpos, ypos));
|
||||
}
|
||||
|
||||
void CCursorHandler::shiftPos( int &x, int &y )
|
||||
{
|
||||
if((mode==1 && number!=6) || mode ==3)
|
||||
|
@@ -32,6 +32,7 @@ public:
|
||||
void changeGraphic(const int & type, const int & no); //changes cursor graphic for type type (0 - adventure, 1 - combat, 2 - default, 3 - spellbook) and frame no (not used for type 3)
|
||||
void dragAndDropCursor (SDL_Surface* image); // Replace cursor with a custom image.
|
||||
void draw1();
|
||||
void draw(SDL_Surface *to);
|
||||
|
||||
void shiftPos( int &x, int &y );
|
||||
void draw2();
|
||||
|
@@ -658,6 +658,7 @@ static void listenForEvents()
|
||||
void startGame(StartInfo * options, CConnection *serv/* = NULL*/)
|
||||
{
|
||||
GH.curInt =NULL;
|
||||
SDL_FillRect(screen, 0, 0);
|
||||
if(gOnlyAI)
|
||||
{
|
||||
for(std::map<int, PlayerSettings>::iterator it = options->playerInfos.begin();
|
||||
|
@@ -1337,6 +1337,9 @@ void CPlayerInterface::update()
|
||||
else
|
||||
GH.simpleRedraw();
|
||||
|
||||
if (conf.cc.showFPS)
|
||||
GH.drawFPSCounter();
|
||||
|
||||
// draw the mouse cursor and update the screen
|
||||
// todo: bad way of updating the cursor, update screen should be the last statement of the rendering process
|
||||
CCS->curh->draw1();
|
||||
|
@@ -47,6 +47,7 @@
|
||||
#include "../lib/RegisterTypes.cpp"
|
||||
#include <boost/thread/recursive_mutex.hpp>
|
||||
#include "../CThreadHelper.h"
|
||||
#include "CConfigHandler.h"
|
||||
|
||||
/*
|
||||
* CPreGame.cpp, part of VCMI engine
|
||||
@@ -270,13 +271,14 @@ CMenuScreen::~CMenuScreen()
|
||||
void CMenuScreen::showAll( SDL_Surface * to )
|
||||
{
|
||||
blitAt(CGP->mainbg, 0, 0, to);
|
||||
CCS->videoh->update(pos.x + 8, pos.y + 105, to, true, false);
|
||||
CIntObject::showAll(to);
|
||||
}
|
||||
|
||||
void CMenuScreen::show( SDL_Surface * to )
|
||||
{
|
||||
CIntObject::show(to);
|
||||
CCS->videoh->update(pos.x + 8, pos.y + 105, screen, true, false);
|
||||
//CCS->videoh->update(pos.x + 8, pos.y + 105, screen, true, false);
|
||||
}
|
||||
|
||||
void CMenuScreen::moveTo( CMenuScreen *next )
|
||||
@@ -337,31 +339,33 @@ void CGPreGame::disposeGraphics()
|
||||
|
||||
void CGPreGame::update()
|
||||
{
|
||||
SDL_FillRect(screen, 0, 0);
|
||||
|
||||
if (GH.listInt.size() == 0)
|
||||
{
|
||||
CCS->musich->playMusic(musicBase::mainMenu, -1);
|
||||
#ifdef _WIN32
|
||||
CCS->videoh->open("ACREDIT.SMK");
|
||||
#else
|
||||
CCS->videoh->open("ACREDIT.SMK", true, false);
|
||||
#endif
|
||||
GH.pushInt(scrs[CMenuScreen::mainMenu]);
|
||||
}
|
||||
|
||||
if(SEL)
|
||||
SEL->update();
|
||||
|
||||
// draw the mouse cursor and update the screen
|
||||
// todo: bad way of updating the cursor, update screen should be the last statement of the rendering process
|
||||
CCS->curh->draw1();
|
||||
CSDL_Ext::update(screen);
|
||||
CCS->curh->draw2();
|
||||
|
||||
GH.topInt()->show(screen);
|
||||
|
||||
// Handles mouse and key input
|
||||
GH.updateTime();
|
||||
GH.handleEvents();
|
||||
|
||||
if (GH.curInt == 0) // no redraw, when a new game was created
|
||||
return;
|
||||
|
||||
GH.totalRedraw();
|
||||
|
||||
if (conf.cc.showFPS)
|
||||
GH.drawFPSCounter();
|
||||
|
||||
// draw the mouse cursor and update the screen
|
||||
CCS->curh->draw(screen);
|
||||
CSDL_Ext::update(screen);
|
||||
}
|
||||
|
||||
CSelectionScreen::CSelectionScreen(CMenuScreen::EState Type, CMenuScreen::EMultiMode MultiPlayer /*= CMenuScreen::SINGLE_PLAYER*/, const std::map<ui32, std::string> *Names /*= NULL*/)
|
||||
@@ -3503,6 +3507,7 @@ CCampaignScreen::CCampaignButton::CCampaignButton(SDL_Surface *bg, const std::st
|
||||
// Create the button hover effect
|
||||
hoverLabel = new CLabel(pos.w / 2., pos.h + 20, FONT_MEDIUM, CENTER, tytulowy, "");
|
||||
hoverLabel->ignoreLeadingWhitespace = false;
|
||||
hoverLabel->autoRedraw = false;
|
||||
}
|
||||
|
||||
CCampaignScreen::CCampaignButton::~CCampaignButton()
|
||||
@@ -3523,19 +3528,18 @@ void CCampaignScreen::CCampaignButton::hover(bool on)
|
||||
{
|
||||
// Deletes the text from the screen when you hover out of the bounds of the button
|
||||
hoverLabel->setTxt(" ");
|
||||
GH.totalRedraw();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CCampaignScreen::CCampaignButton::show(SDL_Surface *to)
|
||||
void CCampaignScreen::CCampaignButton::showAll(SDL_Surface *to)
|
||||
{
|
||||
CIntObject::show(to);
|
||||
CIntObject::showAll(to);
|
||||
|
||||
if (status == CCampaignScreen::DISABLED || video == "" || button == 0)
|
||||
return;
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
// TODO: windows video code seem to have diverged a little bit
|
||||
// from non-windows code. Needs to be fixed and this ifdef removed.
|
||||
|
||||
@@ -3552,7 +3556,7 @@ void CCampaignScreen::CCampaignButton::show(SDL_Surface *to)
|
||||
CCS->videoh->close();
|
||||
blitAt(button, pos, to);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
if (status == CCampaignScreen::COMPLETED) // Draw a checked symbol when you completed the mission
|
||||
{
|
||||
|
@@ -449,7 +449,7 @@ class CCampaignScreen : public CIntObject
|
||||
|
||||
CCampaignButton(SDL_Surface *bg, const std::string image, const int x, const int y, CampaignStatus status); // c-tor
|
||||
~CCampaignButton(); // d-tor
|
||||
void show(SDL_Surface *to);
|
||||
void showAll(SDL_Surface *to);
|
||||
};
|
||||
|
||||
std::vector<CCampaignButton*> campButtons; // a container which holds all buttons where you can start a campaign
|
||||
|
@@ -668,6 +668,7 @@ bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay)
|
||||
{
|
||||
close();
|
||||
|
||||
this->fname = fname;
|
||||
offset = 0;
|
||||
refreshWait = 3;
|
||||
refreshCount = -1;
|
||||
@@ -871,7 +872,10 @@ void CVideoPlayer::update( int x, int y, SDL_Surface *dst, bool forceRedraw, boo
|
||||
refreshCount = refreshWait;
|
||||
if (nextFrame())
|
||||
show(x,y,dst,update);
|
||||
} else {
|
||||
else
|
||||
open(fname);
|
||||
}
|
||||
else {
|
||||
redraw(x, y, dst, update);
|
||||
}
|
||||
|
||||
@@ -880,6 +884,7 @@ void CVideoPlayer::update( int x, int y, SDL_Surface *dst, bool forceRedraw, boo
|
||||
|
||||
void CVideoPlayer::close()
|
||||
{
|
||||
fname = "";
|
||||
if (sws) {
|
||||
sws_freeContext(sws);
|
||||
sws = NULL;
|
||||
|
@@ -235,7 +235,7 @@ public:
|
||||
~CVideoPlayer();
|
||||
|
||||
bool init();
|
||||
bool open(std::string fname, bool loop=false, bool useOverlay=false);
|
||||
bool open(std::string fname, bool loop = false, bool useOverlay = false);
|
||||
void close();
|
||||
bool nextFrame(); // display next frame
|
||||
|
||||
@@ -250,6 +250,7 @@ public:
|
||||
const char *data; // video buffer
|
||||
int length; // video size
|
||||
unsigned int offset; // current data offset
|
||||
std::string fname; //name of current video file (empty if idle)
|
||||
};
|
||||
|
||||
#define VIDEO_WIN "win3.mjpg"
|
||||
|
@@ -10,6 +10,7 @@
|
||||
#include "Graphics.h"
|
||||
#include "../CThreadHelper.h"
|
||||
#include "CConfigHandler.h"
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
/*
|
||||
* GUIBase.cpp, part of VCMI engine
|
||||
@@ -370,9 +371,6 @@ void CGuiHandler::run()
|
||||
if(curInt)
|
||||
curInt->update(); // calls a update and drawing process of the loaded game interface object at the moment
|
||||
|
||||
if (conf.cc.showFPS)
|
||||
drawFPSCounter();
|
||||
|
||||
mainFPSmng->framerateDelay(); // holds a constant FPS
|
||||
}
|
||||
} HANDLE_EXCEPTION
|
||||
@@ -406,7 +404,7 @@ void CGuiHandler::drawFPSCounter()
|
||||
static SDL_Rect overlay = { 0, 0, 64, 32};
|
||||
Uint32 black = SDL_MapRGB(screen->format, 10, 10, 10);
|
||||
SDL_FillRect(screen, &overlay, black);
|
||||
std::string fps = toString(mainFPSmng->fps);
|
||||
std::string fps = boost::lexical_cast<std::string>(mainFPSmng->fps);
|
||||
CSDL_Ext::printAt(fps, 10, 10, FONT_BIG, yellow, screen);
|
||||
}
|
||||
|
||||
|
@@ -63,18 +63,18 @@
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<IncludePath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(IncludePath)</IncludePath>
|
||||
<LibraryPath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(LibraryPath)</LibraryPath>
|
||||
<IncludePath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IncludePath)</IncludePath>
|
||||
<IncludePath Condition="'$(Configuration)|$(Platform)'=='RD|Win32'">$(IncludePath)</IncludePath>
|
||||
<LibraryPath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(LibraryPath)</LibraryPath>
|
||||
<LibraryPath Condition="'$(Configuration)|$(Platform)'=='RD|Win32'">$(LibraryPath)</LibraryPath>
|
||||
<IncludePath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">D:\Program Files\boost\boost_1_46_1;$(IncludePath)</IncludePath>
|
||||
<LibraryPath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">D:\Program Files\boost\boost_1_46_1\stage\lib;$(LibraryPath)</LibraryPath>
|
||||
<IncludePath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">C:\C++\boost_1_42_0;$(IncludePath)</IncludePath>
|
||||
<IncludePath Condition="'$(Configuration)|$(Platform)'=='RD|Win32'">C:\C++\boost_1_42_0;$(IncludePath)</IncludePath>
|
||||
<LibraryPath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">C:\C++\boost_1_42_0\stage\lib;$(LibraryPath)</LibraryPath>
|
||||
<LibraryPath Condition="'$(Configuration)|$(Platform)'=='RD|Win32'">C:\C++\boost_1_42_0\stage\lib;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalOptions>/MP4 %(AdditionalOptions)</AdditionalOptions>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>D:\Program Files\boost\boost_1_46_1;..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessToFile>false</PreprocessToFile>
|
||||
<PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
@@ -88,7 +88,7 @@
|
||||
<Link>
|
||||
<AdditionalDependencies>SDL.lib;zdll.lib;SDL_image.lib;SDL_ttf.lib;SDL_mixer.lib;VCMI_lib.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<ShowProgress>NotSet</ShowProgress>
|
||||
<AdditionalLibraryDirectories>../../libs;../;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalLibraryDirectories>D:\Program Files\boost\boost_1_46_1\stage\lib;../../libs;../;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<OptimizeReferences>false</OptimizeReferences>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
@@ -107,7 +107,7 @@
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>D:\Program Files\boost\boost_1_46_1;..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<StringPooling>true</StringPooling>
|
||||
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
@@ -118,7 +118,7 @@
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>SDL.lib;zdll.lib;SDL_image.lib;SDL_ttf.lib;SDL_mixer.lib;VCMI_lib.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>../../libs;../;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalLibraryDirectories>D:\Program Files\boost\boost_1_46_1\stage\lib;../../libs;../;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<Driver>NotSet</Driver>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
|
10
global.h
10
global.h
@@ -370,16 +370,6 @@ enum EAlignment
|
||||
GOOD, EVIL, NEUTRAL
|
||||
};
|
||||
|
||||
// Converts an int/double or any data type you wish to a string
|
||||
template<typename T>
|
||||
std::string toString(const T& value)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << value;
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
|
||||
//uncomment to make it work
|
||||
//#define MARK_BLOCKED_POSITIONS
|
||||
//#define MARK_VISITABLE_POSITIONS
|
||||
|
Reference in New Issue
Block a user