|
From: <shu...@us...> - 2006-11-23 22:37:28
|
Revision: 124
http://svn.sourceforge.net/dunelegacy/?rev=124&view=rev
Author: shutdownrunner
Date: 2006-11-23 14:37:25 -0800 (Thu, 23 Nov 2006)
Log Message:
-----------
- Added label. It will be useful I hope
- And a small test of my image cropping skills. Could someone with a bit of free time make a list of how to cut
images to make menus, in-game panels, etc. ?
Modified Paths:
--------------
branches/dunks/include/Gfx.h
branches/dunks/include/MainMenu.h
branches/dunks/include/OptionsMenu.h
branches/dunks/src/Gfx.cpp
branches/dunks/src/IntroState.cpp
branches/dunks/src/MainMenu.cpp
branches/dunks/src/OptionsMenu.cpp
branches/dunks/src/SConscript
Modified: branches/dunks/include/Gfx.h
===================================================================
--- branches/dunks/include/Gfx.h 2006-11-23 18:30:57 UTC (rev 123)
+++ branches/dunks/include/Gfx.h 2006-11-23 22:37:25 UTC (rev 124)
@@ -113,7 +113,6 @@
*/
SDL_Surface* resizeSurface(SDL_Surface *surface, double ratio);
-void scale2x(SDL_Surface *src, SDL_Surface *dst);
//@}
//------------------------------------------------------------------------------
Modified: branches/dunks/include/MainMenu.h
===================================================================
--- branches/dunks/include/MainMenu.h 2006-11-23 18:30:57 UTC (rev 123)
+++ branches/dunks/include/MainMenu.h 2006-11-23 22:37:25 UTC (rev 124)
@@ -4,6 +4,8 @@
#include "MenuBase.h"
#include "gui2/Button.h"
#include "gui2/VBox.h"
+#include "Gfx.h"
+#include "SDL.h"
class MainMenuState : public MenuBaseState
{
@@ -15,11 +17,13 @@
void doSkirmish();
void doSingle();
void doQuit();
+ int Execute(float dt);
virtual const char* GetName() { return "MainMenuState"; }
private:
VBox* m_vbox;
-
+ Rect m_rect;
+ SDL_Surface * m_surf;
BoringButton* m_butSingle;
BoringButton* m_butMulti;
BoringButton* m_butMapEd;
Modified: branches/dunks/include/OptionsMenu.h
===================================================================
--- branches/dunks/include/OptionsMenu.h 2006-11-23 18:30:57 UTC (rev 123)
+++ branches/dunks/include/OptionsMenu.h 2006-11-23 22:37:25 UTC (rev 124)
@@ -4,7 +4,6 @@
#include "MenuBase.h"
#include "gui2/Button.h"
#include "gui2/VBox.h"
-
#include "SDL.h"
@@ -23,7 +22,6 @@
private:
VBox* m_vbox;
-
BoringButton* m_butResolution;
BoringButton* m_butWindowMode;
BoringButton* m_butOk;
Modified: branches/dunks/src/Gfx.cpp
===================================================================
--- branches/dunks/src/Gfx.cpp 2006-11-23 18:30:57 UTC (rev 123)
+++ branches/dunks/src/Gfx.cpp 2006-11-23 22:37:25 UTC (rev 124)
@@ -316,54 +316,6 @@
return resizeSurface(surface, (Uint16)(surface->w*ratio), (Uint16)(surface->h*ratio));
}
-// Defines used by scale2x
-
-#ifndef MAX
-#define MAX(a,b) (((a) > (b)) ? (a) : (b))
-#define MIN(a,b) (((a) < (b)) ? (a) : (b))
-#endif
-
-
-#define READINT24(x) ((x)[0]<<16 | (x)[1]<<8 | (x)[2])
-#define WRITEINT24(x, i) {(x)[0]=i>>16; (x)[1]=(i>>8)&0xff; x[2]=i&0xff; }
-
-
-void scale2x(SDL_Surface *src, SDL_Surface *dst)
-{
- int looph, loopw;
-
- Uint8* srcpix = (Uint8*)src->pixels;
- Uint8* dstpix = (Uint8*)dst->pixels;
-
- const int srcpitch = src->pitch;
- const int dstpitch = dst->pitch;
- const int width = src->w;
- const int height = src->h;
-
-
- Uint8 E0, E1, E2, E3, B, D, E, F, H;
- for(looph = 0; looph < height; ++looph)
- {
- for(loopw = 0; loopw < width; ++ loopw)
- {
- B = *(Uint8*)(srcpix + (MAX(0,looph-1)*srcpitch) + (1*loopw));
- D = *(Uint8*)(srcpix + (looph*srcpitch) + (1*MAX(0,loopw-1)));
- E = *(Uint8*)(srcpix + (looph*srcpitch) + (1*loopw));
- F = *(Uint8*)(srcpix + (looph*srcpitch) + (1*MIN(width-1,loopw+1)));
- H = *(Uint8*)(srcpix + (MIN(height-1,looph+1)*srcpitch) + (1*loopw));
-
- E0 = D == B && B != F && D != H ? D : E;
- E1 = B == F && B != D && F != H ? F : E;
- E2 = D == H && D != B && H != F ? D : E;
- E3 = H == F && D != H && B != F ? F : E;
-
- *(Uint8*)(dstpix + looph*2*dstpitch + loopw*2*1) = E0;
- *(Uint8*)(dstpix + looph*2*dstpitch + (loopw*2+1)*1) = E1;
- *(Uint8*)(dstpix + (looph*2+1)*dstpitch + loopw*2*1) = E2;
- *(Uint8*)(dstpix + (looph*2+1)*dstpitch + (loopw*2+1)*1) = E3;
- }
- }
-}
//------------------------------------------------------------------------------
// Color mapping
//------------------------------------------------------------------------------
Modified: branches/dunks/src/IntroState.cpp
===================================================================
--- branches/dunks/src/IntroState.cpp 2006-11-23 18:30:57 UTC (rev 123)
+++ branches/dunks/src/IntroState.cpp 2006-11-23 22:37:25 UTC (rev 124)
@@ -1,6 +1,7 @@
#include "IntroState.h"
#include "ResMan.h"
#include "Application.h"
+#include "Gfx.h"
#include "Settings.h"
#include "pakfile/Palette.h"
#include "boost/bind.hpp"
@@ -58,7 +59,7 @@
SDL_SetColors(m_scaledSurface, palette->colors, 0, palette->ncolors);
- scale2x(m_animSurface, m_scaledSurface);
+ m_scaledSurface = resizeSurface(m_animSurface, 2);
}
bool IntroState::Frame::Execute(float dt)
@@ -119,7 +120,7 @@
SDL_SetColors(m_scaledSurface, palette->colors, 0, palette->ncolors);
- scale2x(m_animSurface, m_scaledSurface);
+ m_scaledSurface = resizeSurface(m_animSurface, 2);
};
};
}
Modified: branches/dunks/src/MainMenu.cpp
===================================================================
--- branches/dunks/src/MainMenu.cpp 2006-11-23 18:30:57 UTC (rev 123)
+++ branches/dunks/src/MainMenu.cpp 2006-11-23 22:37:25 UTC (rev 124)
@@ -3,13 +3,13 @@
#include "Application.h"
//#include "DataFile.h"
#include "Settings.h"
-
+#include "ResMan.h"
#include "SingleMenu.h"
#include "OptionsMenu.h"
#include "boost/bind.hpp"
+#include "pakfile/Wsafile.h"
-
MainMenuState::MainMenuState()
{
//m_menuBackground = (SDL_Surface*)(dataFile[UI_Menu].dat);
@@ -83,6 +83,53 @@
m_vbox->reshape();
m_container->addChild(m_vbox);
+
+//TODO:I guess that most of this should be wrapped into some function as
+//we'll be doing a lot of image cropping like this
+
+ int len;
+ unsigned char * data = ResMan::Instance()->readFile("MENTAT:FARTR.WSA", &len);
+
+ SDL_Palette* palette = Application::Instance()->Screen()->format->palette;
+
+ Wsafile * m_wsa = new Wsafile(data, len);
+
+ SDL_Surface * tmp = copySurface(m_wsa->getPicture(1, palette));
+
+ m_surf = SDL_CreateRGBSurface(SDL_SWSURFACE, 258, 65, 8,0,0,0,0);
+
+ SDL_SetColors(m_surf, palette->colors, 0, palette->ncolors);
+
+ Rect src (6,31, 82, 65);
+
+ Rect cp(0, 0, 82, 65);
+
+ SDL_BlitSurface(tmp, &src, m_surf, &cp);
+
+
+ data = ResMan::Instance()->readFile("MENTAT:FHARK.WSA", &len);
+
+ m_wsa = new Wsafile(data, len);
+ tmp = copySurface(m_wsa->getPicture(1, palette));
+
+ cp.setPosition(SPoint(88, 0));
+
+ SDL_BlitSurface(tmp, &src, m_surf, &cp);
+
+ data = ResMan::Instance()->readFile("MENTAT:FORDOS.WSA", &len);
+
+ m_wsa = new Wsafile(data, len);
+ tmp = copySurface(m_wsa->getPicture(1, palette));
+
+ cp.setPosition(SPoint(176, 0));
+ SDL_BlitSurface(tmp, &src, m_surf, &cp);
+
+ m_surf = resizeSurface(m_surf, 2);
+
+ m_rect.setPosition(SPoint(Settings::Instance()->GetWidth() / 2 - m_surf->w/2,
+ Settings::Instance()->GetHeight() / 4));
+
+ m_rect.setSize(UPoint(m_surf->w, m_surf->h));
}
MainMenuState::~MainMenuState()
@@ -128,13 +175,12 @@
{
Application::Instance()->RootWidget()->deleteChild(m_vbox);
State::JustMadeInactive();
-}
+}*/
int MainMenuState::Execute(float dt)
{
- Application::Instance()->BlitCentered(m_menuBackground);
+ Application::Instance()->Blit(m_surf, NULL, &m_rect);
return 0;
}
-*/
Modified: branches/dunks/src/OptionsMenu.cpp
===================================================================
--- branches/dunks/src/OptionsMenu.cpp 2006-11-23 18:30:57 UTC (rev 123)
+++ branches/dunks/src/OptionsMenu.cpp 2006-11-23 22:37:25 UTC (rev 124)
@@ -2,6 +2,9 @@
#include "Application.h"
//#include "DataFile.h"
+#include "ResMan.h"
+#include "Gfx.h"
+#include "pakfile/Wsafile.h"
#include "Settings.h"
#include "boost/bind.hpp"
@@ -65,8 +68,8 @@
(m_vbox->w / 2);
m_vbox->setPosition(UPoint(x - 5, 312));
m_vbox->reshape();
-
m_container->addChild(m_vbox);
+
}
OptionsMenuState::~OptionsMenuState()
@@ -125,4 +128,3 @@
else
m_butWindowMode->setCaption("Window mode");
}
-
Modified: branches/dunks/src/SConscript
===================================================================
--- branches/dunks/src/SConscript 2006-11-23 18:30:57 UTC (rev 123)
+++ branches/dunks/src/SConscript 2006-11-23 22:37:25 UTC (rev 124)
@@ -39,6 +39,7 @@
"gui2/Container.cpp",
"gui2/Button.cpp",
"gui2/VBox.cpp",
+ "gui2/Label.cpp",
]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|