Skip to content

Commit

Permalink
Merge branch 'sprites'
Browse files Browse the repository at this point in the history
  • Loading branch information
bradallred committed Jul 5, 2013
2 parents 071c7bf + 75192d5 commit 04f5148
Show file tree
Hide file tree
Showing 38 changed files with 912 additions and 696 deletions.
26 changes: 21 additions & 5 deletions apple/GemRB.xcodeproj/project.pbxproj
Expand Up @@ -664,6 +664,10 @@
A2E9967814DE05590052BABE /* ZLibManager.so in CopyFiles */ = {isa = PBXBuildFile; fileRef = A276B4AF13A28AEE00D41A8A /* ZLibManager.so */; };
A2E9967914DE05590052BABE /* STOImporter.so in CopyFiles */ = {isa = PBXBuildFile; fileRef = A276B4F413A28C0400D41A8A /* STOImporter.so */; };
A2E9967A14DE05590052BABE /* SAVImporter.so in CopyFiles */ = {isa = PBXBuildFile; fileRef = A2F0505113ABB80B0023B7EB /* SAVImporter.so */; };
A2EC2F90176BD28E00FD960E /* BAMSprite2D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A2EC2F8E176BD28E00FD960E /* BAMSprite2D.cpp */; };
A2EC2F91176BD28E00FD960E /* BAMSprite2D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A2EC2F8E176BD28E00FD960E /* BAMSprite2D.cpp */; };
A2EC2F94176BD44C00FD960E /* SDLSurfaceSprite2D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A2EC2F92176BD44C00FD960E /* SDLSurfaceSprite2D.cpp */; };
A2EC2F95176BD44D00FD960E /* SDLSurfaceSprite2D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A2EC2F92176BD44C00FD960E /* SDLSurfaceSprite2D.cpp */; };
A2EC8059145F9E6E0033754A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A2EC8058145F9E6E0033754A /* Foundation.framework */; };
A2EC805B1460556B0033754A /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A2EC805A1460556B0033754A /* OpenAL.framework */; };
A2EC805D1460559C0033754A /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A2EC805C1460559C0033754A /* CoreAudio.framework */; };
Expand Down Expand Up @@ -1661,6 +1665,10 @@
A2E27EF616EEA7B00079E104 /* InterfaceConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InterfaceConfig.h; sourceTree = "<group>"; };
A2E27EFB16F12B5A0079E104 /* GemRB.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = GemRB.xib; path = CocoaWrapper/mac/nibs/GemRB.xib; sourceTree = "<group>"; };
A2E6646F139E8DFA00310FC8 /* libgemrb_core.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libgemrb_core.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
A2EC2F8E176BD28E00FD960E /* BAMSprite2D.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BAMSprite2D.cpp; sourceTree = "<group>"; };
A2EC2F8F176BD28E00FD960E /* BAMSprite2D.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BAMSprite2D.h; sourceTree = "<group>"; };
A2EC2F92176BD44C00FD960E /* SDLSurfaceSprite2D.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SDLSurfaceSprite2D.cpp; sourceTree = "<group>"; };
A2EC2F93176BD44C00FD960E /* SDLSurfaceSprite2D.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLSurfaceSprite2D.h; sourceTree = "<group>"; };
A2EC8058145F9E6E0033754A /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; };
A2EC805A1460556B0033754A /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/System/Library/Frameworks/OpenAL.framework; sourceTree = DEVELOPER_DIR; };
A2EC805C1460559C0033754A /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudio.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/System/Library/Frameworks/CoreAudio.framework; sourceTree = DEVELOPER_DIR; };
Expand Down Expand Up @@ -2358,6 +2366,8 @@
A28D24A3143C24E500A27897 /* BAMFontManager.h */,
A27B86AD139F0A7D0002DC13 /* BAMImporter.cpp */,
A27B86AE139F0A7D0002DC13 /* BAMImporter.h */,
A2EC2F8E176BD28E00FD960E /* BAMSprite2D.cpp */,
A2EC2F8F176BD28E00FD960E /* BAMSprite2D.h */,
);
path = BAMImporter;
sourceTree = "<group>";
Expand Down Expand Up @@ -2641,15 +2651,17 @@
A27B8757139F0A7D0002DC13 /* SDLVideo */ = {
isa = PBXGroup;
children = (
A2DB6D5715D9ECB300D70E88 /* SpriteRenderer.inl */,
A2DB6D5815D9ECB300D70E88 /* TileRenderer.inl */,
A298DD1714EB4EEB00F59F56 /* SDL20Video.cpp */,
A298DD1814EB4EEB00F59F56 /* SDL20Video.h */,
A249187B141075A60038B170 /* CocoaWrapper.m */,
A298DD1314EB4EDE00F59F56 /* SDL12Video.cpp */,
A298DD1414EB4EDE00F59F56 /* SDL12Video.h */,
A249187B141075A60038B170 /* CocoaWrapper.m */,
A298DD1714EB4EEB00F59F56 /* SDL20Video.cpp */,
A298DD1814EB4EEB00F59F56 /* SDL20Video.h */,
A2EC2F92176BD44C00FD960E /* SDLSurfaceSprite2D.cpp */,
A2EC2F93176BD44C00FD960E /* SDLSurfaceSprite2D.h */,
A27B875A139F0A7D0002DC13 /* SDLVideo.cpp */,
A27B875B139F0A7D0002DC13 /* SDLVideo.h */,
A2DB6D5715D9ECB300D70E88 /* SpriteRenderer.inl */,
A2DB6D5815D9ECB300D70E88 /* TileRenderer.inl */,
);
path = SDLVideo;
sourceTree = "<group>";
Expand Down Expand Up @@ -4597,6 +4609,7 @@
A22693791422934E004468E8 /* CocoaWrapper.m in Sources */,
A276B4EF13A28BE100D41A8A /* SDLVideo.cpp in Sources */,
A298DD1614EB4EDE00F59F56 /* SDL12Video.cpp in Sources */,
A2EC2F95176BD44D00FD960E /* SDLSurfaceSprite2D.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -4700,6 +4713,7 @@
A2B0CCD61486FF780074E54B /* BAMFontManager.cpp in Sources */,
A29BF82B13A03DFC00C812DD /* BAMImporter.cpp in Sources */,
A2A2EA3016A5EB4C0092B903 /* BAMFont.cpp in Sources */,
A2EC2F91176BD28E00FD960E /* BAMSprite2D.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -4902,6 +4916,8 @@
A2A2EA2F16A5EB4C0092B903 /* BAMFont.cpp in Sources */,
A2A2EA3416A5EB630092B903 /* TTFFont.cpp in Sources */,
A2A2EA3816A5FC860092B903 /* Freetype.cpp in Sources */,
A2EC2F90176BD28E00FD960E /* BAMSprite2D.cpp in Sources */,
A2EC2F94176BD44C00FD960E /* SDLSurfaceSprite2D.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
8 changes: 3 additions & 5 deletions gemrb/core/Animation.cpp
Expand Up @@ -53,10 +53,8 @@ Animation::Animation(int count)

Animation::~Animation(void)
{
Video *video = core->GetVideoDriver();

for (unsigned int i = 0; i < indicesCount; i++) {
video->FreeSprite( frames[i] );
frames[i]->release();
}
free(frames);
}
Expand Down Expand Up @@ -221,7 +219,7 @@ void Animation::MirrorAnimation()
for (size_t i = 0; i < indicesCount; i++) {
Sprite2D * tmp = frames[i];
frames[i] = video->MirrorSpriteHorizontal( tmp, true );
video->FreeSprite(tmp);
tmp->release();
}

// flip animArea horizontally as well
Expand All @@ -235,7 +233,7 @@ void Animation::MirrorAnimationVert()
for (size_t i = 0; i < indicesCount; i++) {
Sprite2D * tmp = frames[i];
frames[i] = video->MirrorSpriteVertical( tmp, true );
video->FreeSprite(tmp);
tmp->release();
}

// flip animArea vertically as well
Expand Down
11 changes: 3 additions & 8 deletions gemrb/core/AnimationFactory.cpp
Expand Up @@ -24,7 +24,6 @@

#include "Interface.h"
#include "Sprite2D.h"
#include "Video.h"

namespace GemRB {

Expand All @@ -39,7 +38,7 @@ AnimationFactory::AnimationFactory(const char* ResRef)
AnimationFactory::~AnimationFactory(void)
{
for (unsigned int i = 0; i < frames.size(); i++) {
core->GetVideoDriver()->FreeSprite( frames[i] );
frames[i]->release();
}
if (FLTable)
free( FLTable);
Expand Down Expand Up @@ -127,8 +126,7 @@ Sprite2D* AnimationFactory::GetPaperdollImage(ieDword *Colors,
return NULL;
}

Video* video = core->GetVideoDriver();
Picture2 = video->DuplicateSprite(frames[1]);
Picture2 = frames[1]->copy();
if (!Picture2) {
return NULL;
}
Expand All @@ -142,8 +140,7 @@ Sprite2D* AnimationFactory::GetPaperdollImage(ieDword *Colors,
Picture2->XPos = (short)frames[1]->XPos;
Picture2->YPos = (short)frames[1]->YPos - 80;


Sprite2D* spr = core->GetVideoDriver()->DuplicateSprite(frames[0]);
Sprite2D* spr = frames[0]->copy();
if (Colors) {
Palette* palette = spr->GetPalette();
palette->SetupPaperdollColours(Colors, type);
Expand All @@ -154,8 +151,6 @@ Sprite2D* AnimationFactory::GetPaperdollImage(ieDword *Colors,
spr->XPos = (short)frames[0]->XPos;
spr->YPos = (short)frames[0]->YPos;

//don't free pixels, createsprite stores it in spr

return spr;
}

Expand Down
1 change: 0 additions & 1 deletion gemrb/core/CharAnimations.cpp
Expand Up @@ -30,7 +30,6 @@
#include "Interface.h"
#include "Map.h"
#include "Palette.h"
#include "Video.h"

namespace GemRB {

Expand Down
2 changes: 0 additions & 2 deletions gemrb/core/ControlAnimation.cpp
Expand Up @@ -26,8 +26,6 @@
#include "GameData.h"
#include "GlobalTimer.h"
#include "Interface.h"
#include "Palette.h" /* needed only for paperdoll palettes */
#include "Video.h" /* needed only for paperdoll palettes */
#include "GUI/Button.h"

namespace GemRB {
Expand Down
5 changes: 3 additions & 2 deletions gemrb/core/GUI/GameControl.cpp
Expand Up @@ -1610,8 +1610,9 @@ void GameControl::UpdateScrolling() {
}

Sprite2D* cursor = core->GetScrollCursorSprite(cursorFrame, numScrollCursor);
core->GetVideoDriver()->SetCursor(cursor, VID_CUR_DRAG);
cursor->release();
Video* video = core->GetVideoDriver();
video->SetCursor(cursor, VID_CUR_DRAG);
video->FreeSprite(cursor);

numScrollCursor = (numScrollCursor+1) % 15;
}
Expand Down
3 changes: 1 addition & 2 deletions gemrb/core/ImageFactory.cpp
Expand Up @@ -21,7 +21,6 @@
#include "ImageFactory.h"

#include "Interface.h"
#include "Video.h"

namespace GemRB {

Expand All @@ -33,7 +32,7 @@ ImageFactory::ImageFactory(const char* ResRef, Sprite2D* bitmap_)

ImageFactory::~ImageFactory(void)
{
core->GetVideoDriver()->FreeSprite( bitmap );
bitmap->release();
}

Sprite2D* ImageFactory::GetSprite2D() const
Expand Down
5 changes: 2 additions & 3 deletions gemrb/core/ImageMgr.cpp
Expand Up @@ -24,7 +24,6 @@

#include "ImageFactory.h"
#include "Interface.h"
#include "Video.h"

namespace GemRB {

Expand Down Expand Up @@ -55,7 +54,7 @@ Bitmap* ImageMgr::GetBitmap()
}
}

core->GetVideoDriver()->FreeSprite(spr);
spr->release();

return data;
}
Expand All @@ -74,7 +73,7 @@ Image* ImageMgr::GetImage()
}
}

core->GetVideoDriver()->FreeSprite(spr);
spr->release();

return data;
}
Expand Down
20 changes: 12 additions & 8 deletions gemrb/core/Interface.cpp
Expand Up @@ -201,7 +201,6 @@ Interface::Interface()
TooltipDelay = 100;
IgnoreOriginalINI = 0;
Bpp = 32;
FullScreen = 0;
GUIScriptsPath[0] = 0;
GamePath[0] = 0;
SavePath[0] = 0;
Expand Down Expand Up @@ -1128,16 +1127,9 @@ static const Region bg( 0, 0, 100, 30 );
/** this is the main loop */
void Interface::Main()
{
ieDword brightness = 10;
ieDword contrast = 5;
ieDword speed = 10;

vars->Lookup("Full Screen", FullScreen);
video->CreateDisplay( Width, Height, Bpp, FullScreen, GameName);
vars->Lookup("Brightness Correction", brightness);
vars->Lookup("Gamma Correction", contrast);
vars->Lookup("Mouse Scroll Speed", speed);
video->SetGamma(brightness, contrast);
SetMouseScrollSpeed((int) speed);
if (vars->Lookup("Tooltips", TooltipDelay)) {
// the games store the slider position*10, not the actual delay
Expand Down Expand Up @@ -1503,6 +1495,7 @@ int Interface::Init(InterfaceConfig* config)
CONFIG_INT("EnableCheatKeys", EnableCheatKeys);
CONFIG_INT("EndianSwitch", DataStream::SetEndianSwitch);
CONFIG_INT("FogOfWar", FogOfWar = );
ieDword FullScreen = 0;
CONFIG_INT("FullScreen", FullScreen = );
vars->SetAt("Full Screen", FullScreen); //put into vars so that reading from game.ini wont overwrite
CONFIG_INT("GUIEnhancements", GUIEnhancements = );
Expand Down Expand Up @@ -1684,6 +1677,17 @@ int Interface::Init(InterfaceConfig* config)
Log(FATAL, "Core", "Cannot Initialize Video Driver.");
return GEM_ERROR;
}
ieDword brightness = 10;
ieDword contrast = 5;

// SDL2 driver requires the display to be created prior to sprite creation (opengl context)
// we also need the display to exist to create sprites using the display format
vars->Lookup("Full Screen", FullScreen);
video->CreateDisplay( Width, Height, Bpp, FullScreen, GameName);
vars->Lookup("Brightness Correction", brightness);
vars->Lookup("Gamma Correction", contrast);
video->SetGamma(brightness, contrast);

Color defcolor={255,255,255,200};
SetInfoTextColor(defcolor);

Expand Down
1 change: 0 additions & 1 deletion gemrb/core/Interface.h
Expand Up @@ -337,7 +337,6 @@ class GEM_EXPORT Interface
ieResRef ScrollCursorBam;
ieResRef GroundCircleBam[MAX_CIRCLE_SIZE];
int GroundCircleScale[MAX_CIRCLE_SIZE];
ieDword FullScreen;
ieResRef TooltipFont;
ieResRef TooltipBackResRef;
ieResRef MovieFont;
Expand Down
1 change: 0 additions & 1 deletion gemrb/core/SaveGameIterator.cpp
Expand Up @@ -33,7 +33,6 @@
#include "SaveGameMgr.h"
#include "Sprite2D.h"
#include "TableMgr.h"
#include "Video.h"
#include "GUI/GameControl.h"
#include "Scriptable/Actor.h"
#include "System/FileStream.h"
Expand Down
1 change: 0 additions & 1 deletion gemrb/core/Scriptable/Door.cpp
Expand Up @@ -33,7 +33,6 @@
#include "Spell.h"
#include "SpriteCover.h"
#include "TileMap.h"
#include "Video.h"
#include "GameScript/GSUtils.h"
#include "GUI/GameControl.h"
#include "Scriptable/InfoPoint.h"
Expand Down
1 change: 0 additions & 1 deletion gemrb/core/Scriptable/InfoPoint.cpp
Expand Up @@ -34,7 +34,6 @@
#include "Spell.h"
#include "SpriteCover.h"
#include "TileMap.h"
#include "Video.h"
#include "GameScript/GSUtils.h"
#include "GUI/GameControl.h"
#include "System/StringBuffer.h"
Expand Down

0 comments on commit 04f5148

Please sign in to comment.