sdl backend now compiles and links, but doesn't yet run (missing mainloop)

master
Per Inge Mathisen 2011-12-13 18:44:21 +01:00
parent 8f047f71fd
commit 0ee5bb3547
6 changed files with 65 additions and 17 deletions

View File

@ -147,16 +147,14 @@ esac
AM_CONDITIONAL([MINGW32], test "x$host_os_mingw32" = "xyes")
# Check for X11 (for qtgame)
if test "x$backend" = "xqt"; then
if test "x$host_os_mingw32" != "xyes" ; then
X_LIBS=""
AC_PATH_X
if test x$no_x != "xyes"; then
X_LIBS="-lX11 -lXrandr ${X_LIBS}"
fi
AC_SUBST(X_LIBS)
# Check for X11 (for qtgame and scrap)
if test "x$host_os_mingw32" != "xyes" ; then
X_LIBS=""
AC_PATH_X
if test x$no_x != "xyes"; then
X_LIBS="-lX11 -lXrandr ${X_LIBS}"
fi
AC_SUBST(X_LIBS)
fi
# Set compilers to use when building for the build system in a cross compile build

View File

@ -56,6 +56,7 @@ void wzFatalDialog(const char *text); ///< Throw up a modal warning dialog
QList<QSize> wzAvailableResolutions(); ///< Get list of available resolutions.
void wzSetSwapInterval(bool swap);
bool wzGetSwapInterval();
QString wzGetSelection();
// Thread related
WZ_THREAD *wzThreadCreate(int (*threadFunc)(void *), void *data);

View File

@ -28,6 +28,8 @@
#include <QtGui/QMouseEvent>
#include <QtGui/QMessageBox>
#include <QtGui/QIcon>
#include <QtGui/QApplication>
#include <QtGui/QClipboard>
// Get platform defines before checking for them.
// Qt headers MUST come before platform specific stuff!
@ -1154,6 +1156,15 @@ void iV_SetTextSize(float size)
}
#endif
QString wzGetSelection()
{
QString aText;
QClipboard *clipboard = QApplication::clipboard();
aText = clipboard->text(QClipboard::Selection); // try X11 specific buffer first
if (aText.isEmpty()) aText = clipboard->text(QClipboard::Clipboard); // if not, try generic clipboard
return aText;
}
void wzFatalDialog(const char *text)
{
crashing = true;

View File

@ -1,4 +1,4 @@
AM_CPPFLAGS = -DYY_NO_INPUT $(SDL_CFLAGS) $(WZ_CPPFLAGS)
AM_CPPFLAGS = -DYY_NO_INPUT $(SDL_CFLAGS) $(WZ_CPPFLAGS) $(QT4_CFLAGS)
AM_CFLAGS = $(WZ_CFLAGS)
AM_CXXFLAGS = $(WZ_CXXFLAGS)

View File

@ -3,6 +3,9 @@
#include <SDL.h>
#include <SDL_thread.h>
#include <SDL_timer.h>
#include <QtCore/QSize>
#include <QtCore/QString>
#include "scrap.h"
extern void mainLoop();
@ -13,6 +16,46 @@ unsigned int screenHeight = 0;
/*** Misc support ***/
/**************************/
#define WIDG_MAXSTR 80 // HACK, from widget.h
/* Put a character into a text buffer overwriting any text under the cursor */
QString wzGetSelection()
{
QString retval;
static char* scrap = NULL;
int scraplen;
get_scrap(T('T','E','X','T'), &scraplen, &scrap);
if (scraplen > 0 && scraplen < WIDG_MAXSTR-2)
{
retval = QString::fromUtf8(scrap);
}
return retval;
}
void wzSetSwapInterval(bool swap)
{
// TBD
}
bool wzGetSwapInterval()
{
return false; // TBD
}
QList<QSize> wzAvailableResolutions()
{
QList<QSize> list;
int count;
SDL_Rect **modes = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_HWSURFACE);
for (count = 0; modes[count]; count++)
{
QSize s(modes[count]->w, modes[count]->h);
list.push_back(s);
}
return list;
}
void wzSetCursor(CURSOR index)
{
// TBD

View File

@ -22,8 +22,6 @@
*/
#include <string.h>
#include <QtGui/QApplication>
#include <QtGui/QClipboard>
#include "lib/framework/frame.h"
#include "lib/framework/utf.h"
@ -155,6 +153,7 @@ void W_EDITBOX::overwriteChar(QChar ch)
++insPos;
}
/* Delete a character to the right of the position */
void W_EDITBOX::delCharRight()
{
@ -411,11 +410,7 @@ void W_EDITBOX::run(W_CONTEXT *psContext)
switch (key)
{
case KEY_V:
{
QClipboard *clipboard = QApplication::clipboard();
aText = clipboard->text(QClipboard::Selection); // try X11 specific buffer first
if (aText.isEmpty()) aText = clipboard->text(QClipboard::Clipboard); // if not, try generic clipboard
}
aText = wzGetSelection();
insPos = aText.length();
/* Update the printable text */
fitStringEnd();