qt-sdl: Fix input, mouse cursor, skirmish.

Now runs, and is at least a bit usable.
master
Cyp 2011-12-15 11:27:48 +01:00
parent 8e1c6578a1
commit 8c7c110c24
9 changed files with 1417 additions and 13 deletions

23
3rdparty/SDL/mac/include/SDL_mouse.h vendored Normal file
View File

@ -0,0 +1,23 @@
/*
This file is part of Warzone 2100.
Copyright (C) 2011 Warzone 2100 Project
Warzone 2100 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 2 of the License, or
(at your option) any later version.
Warzone 2100 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 Warzone 2100; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/** @file
* @brief Platform independent SDL inclusion.
*/
#include <SDL/SDL_mouse.h>

View File

@ -45,6 +45,7 @@ void wzMain(int &argc, char **argv);
bool wzMain2();
void wzMain3();
void wzQuit(void); ///< Quit game
void wzShutdown();
void wzSetCursor(CURSOR index);
void wzScreenFlip(void); ///< Swap the graphics buffers
void wzShowMouse(bool visible); ///< Show the Mouse?

View File

@ -79,6 +79,14 @@ void wzMain3()
app.exec();
}
void wzShutdown()
{
delete mainWindowPtr;
mainWindowPtr = NULL;
delete appPtr;
appPtr = NULL;
}
QList<QSize> wzAvailableResolutions()
{
return WzMainWindow::instance()->availableResolutions();

View File

@ -742,13 +742,13 @@ void wzShowMouse(bool visible)
void wzSetCursor(CURSOR index)
{
ASSERT(index < CURSOR_MAX, "Attempting to load non-existent cursor: %u", (unsigned int)index);
ASSERT(index < CURSOR_MAX, "Attempting to load non-existent cursor: %u", (unsigned int)index);
if (lastCursor != index)
{
WzMainWindow::instance()->setCursor(index);
lastCursor = index;
}
if (lastCursor != index)
{
WzMainWindow::instance()->setCursor(index);
lastCursor = index;
}
}
void wzGrabMouse()

View File

@ -4,8 +4,10 @@ AM_CXXFLAGS = $(WZ_CXXFLAGS)
noinst_LIBRARIES = libsdl.a
noinst_HEADERS = \
cursors_sdl.h \
scrap.h
libsdl_a_SOURCES = \
cursors_sdl.cpp \
main_sdl.cpp \
scrap.cpp

1328
lib/sdl/cursors_sdl.cpp Normal file

File diff suppressed because it is too large Load Diff

33
lib/sdl/cursors_sdl.h Normal file
View File

@ -0,0 +1,33 @@
/*
This file is part of Warzone 2100.
Copyright (C) 2008 Giel van Schijndel
Copyright (C) 2008-2011 Warzone 2100 Project
Warzone 2100 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 2 of the License, or
(at your option) any later version.
Warzone 2100 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 Warzone 2100; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/** @file
* SDL black/white cursor access functions.
*/
#ifndef __INCLUDED_LIB_SDL_CURSORS_SDL_H__
#define __INCLUDED_LIB_SDL_CURSORS_SDL_H__
#include <SDL_mouse.h>
#include "lib/framework/cursors.h"
void sdlInitCursors();
void sdlFreeCursors();
#endif // __INCLUDED_LIB_SDL_CURSORS_SDL_H__

View File

@ -11,6 +11,7 @@
#include <QtCore/QString>
#include "scrap.h"
#include "wz2100icon.h"
#include "cursors_sdl.h"
extern void mainLoop();
@ -19,6 +20,9 @@ unsigned screenHeight = 0; // Declared in frameint.h.
static unsigned screenDepth = 0;
static SDL_Surface * screen = NULL;
QCoreApplication *appPtr;
/* The possible states for keys */
enum KEY_STATE
{
@ -117,11 +121,6 @@ QList<QSize> wzAvailableResolutions()
return list;
}
void wzSetCursor(CURSOR index)
{
// TBD
}
void wzShowMouse(bool visible)
{
SDL_ShowCursor(visible ? SDL_ENABLE : SDL_DISABLE);
@ -711,7 +710,7 @@ static void inputHandleMouseMotionEvent(SDL_MouseMotionEvent * motionEvent)
void wzMain(int &argc, char **argv)
{
QCoreApplication app(argc, argv); // For Qt-script.
appPtr = new QCoreApplication(argc, argv); // For Qt-script.
}
bool wzMain2()
@ -740,7 +739,7 @@ bool wzMain2()
SDL_WM_SetCaption(PACKAGE_NAME, NULL);
/* initialise all cursors */
//initCursors();
sdlInitCursors();
//END **** Was in old frameInitialise. ****
// TODO Fall back to windowed mode, if fullscreen mode fails.
@ -955,5 +954,14 @@ void wzMain3()
}
}
mainLoop();
inputNewFrame();
}
}
void wzShutdown()
{
sdlFreeCursors();
SDL_Quit();
delete appPtr;
appPtr = NULL;
}

View File

@ -1328,6 +1328,7 @@ int main(int argc, char *argv[])
wzMain3();
saveConfig();
systemShutdown();
wzShutdown();
debug(LOG_MAIN, "Completed shutting down Warzone 2100");
return EXIT_SUCCESS;
}