Merge branches 'bugfixes' and 'widget'
Conflicts: src/ingameop.cpp src/intelmap.cppmaster
commit
64c2fde0dd
|
@ -755,36 +755,6 @@ position = 2940, 6204, 306
|
|||
rotation = 16384, 0, 0
|
||||
name = WreckedSuzukiJeep
|
||||
|
||||
[feature_1395]
|
||||
id = 1395
|
||||
position = 13248, 9664, 6
|
||||
rotation = 0, 0, 0
|
||||
name = OilDrum
|
||||
|
||||
[feature_1396]
|
||||
id = 1396
|
||||
position = 13180, 9548, 12
|
||||
rotation = 0, 0, 0
|
||||
name = OilDrum
|
||||
|
||||
[feature_1397]
|
||||
id = 1397
|
||||
position = 13320, 9624, 0
|
||||
rotation = 0, 0, 0
|
||||
name = OilDrum
|
||||
|
||||
[feature_1398]
|
||||
id = 1398
|
||||
position = 13356, 9748, 4
|
||||
rotation = 0, 0, 0
|
||||
name = OilDrum
|
||||
|
||||
[feature_1399]
|
||||
id = 1399
|
||||
position = 13178, 9728, 13
|
||||
rotation = 0, 0, 0
|
||||
name = OilDrum
|
||||
|
||||
[feature_1400]
|
||||
id = 1400
|
||||
position = 13168, 9612, 15
|
||||
|
@ -935,18 +905,6 @@ position = 10944, 320, 63
|
|||
rotation = 16384, 0, 0
|
||||
name = Ruin3
|
||||
|
||||
[feature_1465]
|
||||
id = 1465
|
||||
position = 9920, 576, 102
|
||||
rotation = 0, 0, 0
|
||||
name = OilDrum
|
||||
|
||||
[feature_1466]
|
||||
id = 1466
|
||||
position = 10304, 576, 102
|
||||
rotation = 49152, 0, 0
|
||||
name = OilDrum
|
||||
|
||||
[feature_1497]
|
||||
id = 1497
|
||||
position = 16192, 9920, 510
|
||||
|
|
|
@ -31,6 +31,10 @@
|
|||
# undef Status
|
||||
#endif
|
||||
|
||||
#ifndef WZ_CXX11
|
||||
# define nullptr NULL
|
||||
#endif
|
||||
|
||||
#include "types.h"
|
||||
/**
|
||||
* NOTE: the next two #include lines are needed by MSVC to override the default,
|
||||
|
|
|
@ -310,6 +310,9 @@
|
|||
*/
|
||||
#if defined(__cplusplus)
|
||||
# define WZ_CXX98
|
||||
# if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
|
||||
# define WZ_CXX11
|
||||
# endif
|
||||
#endif /* WZ_CXXxx */
|
||||
|
||||
|
||||
|
|
|
@ -164,6 +164,7 @@ struct Image
|
|||
{
|
||||
Image(IMAGEFILE const *images = NULL, unsigned id = 0) : images(const_cast<IMAGEFILE *>(images)), id(id) {}
|
||||
|
||||
bool isNull() const { return images == nullptr; }
|
||||
int width() const { return images->imageDefs[id].Width; }
|
||||
int height() const { return images->imageDefs[id].Height; }
|
||||
int xOffset() const { return images->imageDefs[id].XOffset; }
|
||||
|
|
|
@ -117,8 +117,6 @@ static InputKey *pStartBuffer, *pEndBuffer;
|
|||
/*** 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()
|
||||
{
|
||||
|
@ -127,7 +125,7 @@ QString wzGetSelection()
|
|||
int scraplen;
|
||||
|
||||
get_scrap(T('T','E','X','T'), &scraplen, &scrap);
|
||||
if (scraplen > 0 && scraplen < WIDG_MAXSTR-2)
|
||||
if (scraplen > 0)
|
||||
{
|
||||
retval = QString::fromUtf8(scrap);
|
||||
}
|
||||
|
|
|
@ -2,18 +2,42 @@ AM_CPPFLAGS = $(SDL_CFLAGS) $(WZ_CPPFLAGS) $(QT4_CFLAGS)
|
|||
AM_CFLAGS = $(WZ_CFLAGS)
|
||||
AM_CXXFLAGS = $(WZ_CXXFLAGS) $(QT4_CFLAGS)
|
||||
|
||||
noinst_LIBRARIES = libwidget.a
|
||||
noinst_HEADERS = \
|
||||
# Signals/slots
|
||||
MOCHEADER = \
|
||||
bar.h \
|
||||
button.h \
|
||||
editbox.h \
|
||||
form.h \
|
||||
label.h \
|
||||
listwidget.h \
|
||||
slider.h \
|
||||
tip.h \
|
||||
widgbase.h \
|
||||
widget.h \
|
||||
widgint.h
|
||||
MOCEDFILES = $(MOCHEADER:%.h=%_moc.cpp)
|
||||
%_moc.cpp: %.h
|
||||
$(MOC4) -o $@ $<
|
||||
CLEANFILES = \
|
||||
$(MOCEDFILES)
|
||||
|
||||
noinst_LIBRARIES = libwidget.a
|
||||
noinst_HEADERS = \
|
||||
$(MOCHEADER)
|
||||
|
||||
#"nodist_libwidget_a_SOURCES = $(MOCEDFILES)" doesn't work here (not sure why).
|
||||
nodist_libwidget_a_SOURCES = \
|
||||
bar_moc.cpp \
|
||||
button_moc.cpp \
|
||||
editbox_moc.cpp \
|
||||
form_moc.cpp \
|
||||
label_moc.cpp \
|
||||
listwidget_moc.cpp \
|
||||
slider_moc.cpp \
|
||||
tip_moc.cpp \
|
||||
widgbase_moc.cpp \
|
||||
widget_moc.cpp \
|
||||
widgint_moc.cpp
|
||||
|
||||
libwidget_a_SOURCES = \
|
||||
bar.cpp \
|
||||
|
@ -21,6 +45,7 @@ libwidget_a_SOURCES = \
|
|||
editbox.cpp \
|
||||
form.cpp \
|
||||
label.cpp \
|
||||
listwidget.cpp \
|
||||
slider.cpp \
|
||||
tip.cpp \
|
||||
widget.cpp
|
||||
|
|
|
@ -58,83 +58,22 @@ W_BARGRAPH::W_BARGRAPH(W_BARINIT const *init)
|
|||
, majorCol(init->sCol)
|
||||
, minorCol(init->sMinorCol)
|
||||
, textCol(WZCOL_BLACK)
|
||||
, pTip(init->pTip)
|
||||
, pTip(QString::fromUtf8(init->pTip))
|
||||
, backgroundColour(WZCOL_FORM_BACKGROUND)
|
||||
{
|
||||
/* Set the display function */
|
||||
if (display == NULL)
|
||||
{
|
||||
if (init->style & WBAR_TROUGH)
|
||||
{
|
||||
display = barGraphDisplayTrough;
|
||||
}
|
||||
else if (init->style & WBAR_DOUBLE)
|
||||
{
|
||||
display = barGraphDisplayDouble;
|
||||
}
|
||||
else
|
||||
{
|
||||
display = barGraphDisplay;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the minor colour if necessary */
|
||||
// Actually, this sets the major colour to the minor colour. The minor colour used to be left completely uninitialised... Wonder what it was for..?
|
||||
if (style & WBAR_DOUBLE)
|
||||
{
|
||||
majorCol = minorCol;
|
||||
}
|
||||
|
||||
ASSERT((init->style & ~(WBAR_PLAIN | WBAR_TROUGH | WBAR_DOUBLE | WIDG_HIDDEN)) == 0, "Unknown bar graph style");
|
||||
ASSERT(init->orientation >= WBAR_LEFT || init->orientation <= WBAR_BOTTOM, "Unknown orientation");
|
||||
ASSERT(init->size <= WBAR_SCALE, "Bar size out of range");
|
||||
ASSERT((init->style & WBAR_DOUBLE) == 0 || init->minorSize <= WBAR_SCALE, "Minor bar size out of range");
|
||||
}
|
||||
|
||||
/* Create a barGraph widget data structure */
|
||||
W_BARGRAPH *barGraphCreate(const W_BARINIT *psInit)
|
||||
{
|
||||
if (psInit->style & ~(WBAR_PLAIN | WBAR_TROUGH | WBAR_DOUBLE | WIDG_HIDDEN))
|
||||
{
|
||||
ASSERT(false, "Unknown bar graph style");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (psInit->orientation < WBAR_LEFT
|
||||
|| psInit->orientation > WBAR_BOTTOM)
|
||||
{
|
||||
ASSERT(false, "barGraphCreate: Unknown orientation");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (psInit->size > WBAR_SCALE)
|
||||
{
|
||||
ASSERT(false, "barGraphCreate: Bar size out of range");
|
||||
return NULL;
|
||||
}
|
||||
if ((psInit->style & WBAR_DOUBLE)
|
||||
&& (psInit->minorSize > WBAR_SCALE))
|
||||
{
|
||||
ASSERT(false, "barGraphCreate: Minor bar size out of range");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Allocate the required memory */
|
||||
W_BARGRAPH *psWidget = new W_BARGRAPH(psInit);
|
||||
if (psWidget == NULL)
|
||||
{
|
||||
debug(LOG_FATAL, "barGraphCreate: Out of memory");
|
||||
abort();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return psWidget;
|
||||
}
|
||||
|
||||
|
||||
/* Free the memory used by a barGraph */
|
||||
void barGraphFree(W_BARGRAPH *psWidget)
|
||||
{
|
||||
ASSERT(psWidget != NULL, "Invalid widget pointer");
|
||||
|
||||
delete psWidget;
|
||||
}
|
||||
|
||||
|
||||
/* Set the current size of a bar graph */
|
||||
void widgSetBarSize(W_SCREEN *psScreen, UDWORD id, UDWORD iValue)
|
||||
{
|
||||
|
@ -194,24 +133,21 @@ void widgSetMinorBarSize(W_SCREEN *psScreen, UDWORD id, UDWORD iValue)
|
|||
/* Respond to a mouse moving over a barGraph */
|
||||
void W_BARGRAPH::highlight(W_CONTEXT *psContext)
|
||||
{
|
||||
if (pTip)
|
||||
if (!pTip.isEmpty())
|
||||
{
|
||||
tipStart(this, pTip, psContext->psScreen->TipFontID,
|
||||
psContext->psForm->aColours,
|
||||
x + psContext->xOffset, y + psContext->yOffset,
|
||||
width, height);
|
||||
tipStart(this, pTip, screenPointer->TipFontID, x() + psContext->xOffset, y() + psContext->yOffset, width(), height());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Respond to the mouse moving off a barGraph */
|
||||
void W_BARGRAPH::highlightLost(W_CONTEXT *)
|
||||
void W_BARGRAPH::highlightLost()
|
||||
{
|
||||
tipStop(this);
|
||||
}
|
||||
|
||||
|
||||
static void barGraphDisplayText(W_BARGRAPH *barGraph, int x0, int x1, int y1, PIELIGHT *pColours)
|
||||
static void barGraphDisplayText(W_BARGRAPH *barGraph, int x0, int x1, int y1)
|
||||
{
|
||||
if (!barGraph->text.isEmpty())
|
||||
{
|
||||
|
@ -232,7 +168,7 @@ static void barGraphDisplayText(W_BARGRAPH *barGraph, int x0, int x1, int y1, PI
|
|||
}
|
||||
|
||||
/* The simple bar graph display function */
|
||||
void barGraphDisplay(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours)
|
||||
static void barGraphDisplay(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
|
||||
{
|
||||
SDWORD x0 = 0, y0 = 0, x1 = 0, y1 = 0;
|
||||
W_BARGRAPH *psBGraph;
|
||||
|
@ -243,40 +179,40 @@ void barGraphDisplay(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT
|
|||
switch (psBGraph->barPos)
|
||||
{
|
||||
case WBAR_LEFT:
|
||||
x0 = xOffset + psWidget->x;
|
||||
y0 = yOffset + psWidget->y;
|
||||
x1 = x0 + psWidget->width * psBGraph->majorSize / WBAR_SCALE;
|
||||
y1 = y0 + psWidget->height;
|
||||
x0 = xOffset + psWidget->x();
|
||||
y0 = yOffset + psWidget->y();
|
||||
x1 = x0 + psWidget->width() * psBGraph->majorSize / WBAR_SCALE;
|
||||
y1 = y0 + psWidget->height();
|
||||
break;
|
||||
case WBAR_RIGHT:
|
||||
y0 = yOffset + psWidget->y;
|
||||
x1 = xOffset + psWidget->x + psWidget->width;
|
||||
x0 = x1 - psWidget->width * psBGraph->majorSize / WBAR_SCALE;
|
||||
y1 = y0 + psWidget->height;
|
||||
y0 = yOffset + psWidget->y();
|
||||
x1 = xOffset + psWidget->x() + psWidget->width();
|
||||
x0 = x1 - psWidget->width() * psBGraph->majorSize / WBAR_SCALE;
|
||||
y1 = y0 + psWidget->height();
|
||||
break;
|
||||
case WBAR_TOP:
|
||||
x0 = xOffset + psWidget->x;
|
||||
y0 = yOffset + psWidget->y;
|
||||
x1 = x0 + psWidget->width;
|
||||
y1 = y0 + psWidget->height * psBGraph->majorSize / WBAR_SCALE;
|
||||
x0 = xOffset + psWidget->x();
|
||||
y0 = yOffset + psWidget->y();
|
||||
x1 = x0 + psWidget->width();
|
||||
y1 = y0 + psWidget->height() * psBGraph->majorSize / WBAR_SCALE;
|
||||
break;
|
||||
case WBAR_BOTTOM:
|
||||
x0 = xOffset + psWidget->x;
|
||||
x1 = x0 + psWidget->width;
|
||||
y1 = yOffset + psWidget->y + psWidget->height;
|
||||
y0 = y1 - psWidget->height * psBGraph->majorSize / WBAR_SCALE;
|
||||
x0 = xOffset + psWidget->x();
|
||||
x1 = x0 + psWidget->width();
|
||||
y1 = yOffset + psWidget->y() + psWidget->height();
|
||||
y0 = y1 - psWidget->height() * psBGraph->majorSize / WBAR_SCALE;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Now draw the graph */
|
||||
iV_ShadowBox(x0, y0, x1, y1, 0, pColours[WCOL_LIGHT], pColours[WCOL_DARK], psBGraph->majorCol);
|
||||
iV_ShadowBox(x0, y0, x1, y1, 0, WZCOL_FORM_LIGHT, WZCOL_FORM_DARK, psBGraph->majorCol);
|
||||
|
||||
barGraphDisplayText(psBGraph, x0, x1, y1, pColours);
|
||||
barGraphDisplayText(psBGraph, x0, x1, y1);
|
||||
}
|
||||
|
||||
|
||||
/* The double bar graph display function */
|
||||
void barGraphDisplayDouble(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours)
|
||||
static void barGraphDisplayDouble(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
|
||||
{
|
||||
SDWORD x0 = 0, y0 = 0, x1 = 0, y1 = 0, x2 = 0, y2 = 0, x3 = 0, y3 = 0;
|
||||
W_BARGRAPH *psBGraph = (W_BARGRAPH *)psWidget;
|
||||
|
@ -286,73 +222,73 @@ void barGraphDisplayDouble(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIE
|
|||
{
|
||||
case WBAR_LEFT:
|
||||
/* Calculate the major bar */
|
||||
x0 = xOffset + psWidget->x;
|
||||
y0 = yOffset + psWidget->y;
|
||||
x1 = x0 + psWidget->width * psBGraph->majorSize / WBAR_SCALE;
|
||||
y1 = y0 + 2 * psWidget->height / 3;
|
||||
x0 = xOffset + psWidget->x();
|
||||
y0 = yOffset + psWidget->y();
|
||||
x1 = x0 + psWidget->width() * psBGraph->majorSize / WBAR_SCALE;
|
||||
y1 = y0 + 2 * psWidget->height() / 3;
|
||||
|
||||
/* Calculate the minor bar */
|
||||
x2 = x0;
|
||||
y2 = y0 + psWidget->height / 3;
|
||||
x3 = x2 + psWidget->width * psBGraph->minorSize / WBAR_SCALE;
|
||||
y3 = y0 + psWidget->height;
|
||||
y2 = y0 + psWidget->height() / 3;
|
||||
x3 = x2 + psWidget->width() * psBGraph->minorSize / WBAR_SCALE;
|
||||
y3 = y0 + psWidget->height();
|
||||
break;
|
||||
case WBAR_RIGHT:
|
||||
/* Calculate the major bar */
|
||||
y0 = yOffset + psWidget->y;
|
||||
x1 = xOffset + psWidget->x + psWidget->width;
|
||||
x0 = x1 - psWidget->width * psBGraph->majorSize / WBAR_SCALE;
|
||||
y1 = y0 + 2 * psWidget->height / 3;
|
||||
y0 = yOffset + psWidget->y();
|
||||
x1 = xOffset + psWidget->x() + psWidget->width();
|
||||
x0 = x1 - psWidget->width() * psBGraph->majorSize / WBAR_SCALE;
|
||||
y1 = y0 + 2 * psWidget->height() / 3;
|
||||
|
||||
/* Calculate the minor bar */
|
||||
x3 = x1;
|
||||
y2 = y0 + psWidget->height / 3;
|
||||
x2 = x3 - psWidget->width * psBGraph->minorSize / WBAR_SCALE;
|
||||
y3 = y0 + psWidget->height;
|
||||
y2 = y0 + psWidget->height() / 3;
|
||||
x2 = x3 - psWidget->width() * psBGraph->minorSize / WBAR_SCALE;
|
||||
y3 = y0 + psWidget->height();
|
||||
break;
|
||||
case WBAR_TOP:
|
||||
/* Calculate the major bar */
|
||||
x0 = xOffset + psWidget->x;
|
||||
y0 = yOffset + psWidget->y;
|
||||
x1 = x0 + 2 * psWidget->width / 3;
|
||||
y1 = y0 + psWidget->height * psBGraph->majorSize / WBAR_SCALE;
|
||||
x0 = xOffset + psWidget->x();
|
||||
y0 = yOffset + psWidget->y();
|
||||
x1 = x0 + 2 * psWidget->width() / 3;
|
||||
y1 = y0 + psWidget->height() * psBGraph->majorSize / WBAR_SCALE;
|
||||
|
||||
/* Calculate the minor bar */
|
||||
x2 = x0 + psWidget->width / 3;
|
||||
x2 = x0 + psWidget->width() / 3;
|
||||
y2 = y0;
|
||||
x3 = x0 + psWidget->width;
|
||||
y3 = y2 + psWidget->height * psBGraph->minorSize / WBAR_SCALE;
|
||||
x3 = x0 + psWidget->width();
|
||||
y3 = y2 + psWidget->height() * psBGraph->minorSize / WBAR_SCALE;
|
||||
break;
|
||||
case WBAR_BOTTOM:
|
||||
/* Calculate the major bar */
|
||||
x0 = xOffset + psWidget->x;
|
||||
x1 = x0 + 2 * psWidget->width / 3;
|
||||
y1 = yOffset + psWidget->y + psWidget->height;
|
||||
y0 = y1 - psWidget->height * psBGraph->majorSize / WBAR_SCALE;
|
||||
x0 = xOffset + psWidget->x();
|
||||
x1 = x0 + 2 * psWidget->width() / 3;
|
||||
y1 = yOffset + psWidget->y() + psWidget->height();
|
||||
y0 = y1 - psWidget->height() * psBGraph->majorSize / WBAR_SCALE;
|
||||
|
||||
/* Calculate the minor bar */
|
||||
x2 = x0 + psWidget->width / 3;
|
||||
x3 = x0 + psWidget->width;
|
||||
x2 = x0 + psWidget->width() / 3;
|
||||
x3 = x0 + psWidget->width();
|
||||
y3 = y1;
|
||||
y2 = y3 - psWidget->height * psBGraph->minorSize / WBAR_SCALE;
|
||||
y2 = y3 - psWidget->height() * psBGraph->minorSize / WBAR_SCALE;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Draw the minor bar graph */
|
||||
if (psBGraph->minorSize > 0)
|
||||
{
|
||||
iV_ShadowBox(x2, y2, x3, y3, 0, pColours[WCOL_LIGHT], pColours[WCOL_DARK], psBGraph->minorCol);
|
||||
iV_ShadowBox(x2, y2, x3, y3, 0, WZCOL_FORM_LIGHT, WZCOL_FORM_DARK, psBGraph->minorCol);
|
||||
}
|
||||
|
||||
/* Draw the major bar graph */
|
||||
iV_ShadowBox(x0, y0, x1, y1, 0, pColours[WCOL_LIGHT], pColours[WCOL_DARK], psBGraph->majorCol);
|
||||
iV_ShadowBox(x0, y0, x1, y1, 0, WZCOL_FORM_LIGHT, WZCOL_FORM_DARK, psBGraph->majorCol);
|
||||
|
||||
barGraphDisplayText(psBGraph, x0, x1, y1, pColours);
|
||||
barGraphDisplayText(psBGraph, x0, x1, y1);
|
||||
}
|
||||
|
||||
|
||||
/* The trough bar graph display function */
|
||||
void barGraphDisplayTrough(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours)
|
||||
void barGraphDisplayTrough(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
|
||||
{
|
||||
SDWORD x0 = 0, y0 = 0, x1 = 0, y1 = 0; // Position of the bar
|
||||
SDWORD tx0 = 0, ty0 = 0, tx1 = 0, ty1 = 0; // Position of the trough
|
||||
|
@ -363,17 +299,17 @@ void barGraphDisplayTrough(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIE
|
|||
switch (psBGraph->barPos)
|
||||
{
|
||||
case WBAR_LEFT:
|
||||
x0 = xOffset + psWidget->x;
|
||||
y0 = yOffset + psWidget->y;
|
||||
x1 = x0 + psWidget->width * psBGraph->majorSize / WBAR_SCALE;
|
||||
y1 = y0 + psWidget->height;
|
||||
x0 = xOffset + psWidget->x();
|
||||
y0 = yOffset + psWidget->y();
|
||||
x1 = x0 + psWidget->width() * psBGraph->majorSize / WBAR_SCALE;
|
||||
y1 = y0 + psWidget->height();
|
||||
if (x0 == x1)
|
||||
{
|
||||
showBar = false;
|
||||
}
|
||||
tx0 = x1 + 1;
|
||||
ty0 = y0;
|
||||
tx1 = x0 + psWidget->width;
|
||||
tx1 = x0 + psWidget->width();
|
||||
ty1 = y1;
|
||||
if (tx0 >= tx1)
|
||||
{
|
||||
|
@ -381,15 +317,15 @@ void barGraphDisplayTrough(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIE
|
|||
}
|
||||
break;
|
||||
case WBAR_RIGHT:
|
||||
y0 = yOffset + psWidget->y;
|
||||
x1 = xOffset + psWidget->x + psWidget->width;
|
||||
x0 = x1 - psWidget->width * psBGraph->majorSize / WBAR_SCALE;
|
||||
y1 = y0 + psWidget->height;
|
||||
y0 = yOffset + psWidget->y();
|
||||
x1 = xOffset + psWidget->x() + psWidget->width();
|
||||
x0 = x1 - psWidget->width() * psBGraph->majorSize / WBAR_SCALE;
|
||||
y1 = y0 + psWidget->height();
|
||||
if (x0 == x1)
|
||||
{
|
||||
showBar = false;
|
||||
}
|
||||
tx0 = xOffset + psWidget->x;
|
||||
tx0 = xOffset + psWidget->x();
|
||||
ty0 = y0;
|
||||
tx1 = x0 - 1;
|
||||
ty1 = y1;
|
||||
|
@ -399,10 +335,10 @@ void barGraphDisplayTrough(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIE
|
|||
}
|
||||
break;
|
||||
case WBAR_TOP:
|
||||
x0 = xOffset + psWidget->x;
|
||||
y0 = yOffset + psWidget->y;
|
||||
x1 = x0 + psWidget->width;
|
||||
y1 = y0 + psWidget->height * psBGraph->majorSize / WBAR_SCALE;
|
||||
x0 = xOffset + psWidget->x();
|
||||
y0 = yOffset + psWidget->y();
|
||||
x1 = x0 + psWidget->width();
|
||||
y1 = y0 + psWidget->height() * psBGraph->majorSize / WBAR_SCALE;
|
||||
if (y0 == y1)
|
||||
{
|
||||
showBar = false;
|
||||
|
@ -410,23 +346,23 @@ void barGraphDisplayTrough(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIE
|
|||
tx0 = x0;
|
||||
ty0 = y1 + 1;
|
||||
tx1 = x1;
|
||||
ty1 = y0 + psWidget->height;
|
||||
ty1 = y0 + psWidget->height();
|
||||
if (ty0 >= ty1)
|
||||
{
|
||||
showTrough = false;
|
||||
}
|
||||
break;
|
||||
case WBAR_BOTTOM:
|
||||
x0 = xOffset + psWidget->x;
|
||||
x1 = x0 + psWidget->width;
|
||||
y1 = yOffset + psWidget->y + psWidget->height;
|
||||
y0 = y1 - psWidget->height * psBGraph->majorSize / WBAR_SCALE;
|
||||
x0 = xOffset + psWidget->x();
|
||||
x1 = x0 + psWidget->width();
|
||||
y1 = yOffset + psWidget->y() + psWidget->height();
|
||||
y0 = y1 - psWidget->height() * psBGraph->majorSize / WBAR_SCALE;
|
||||
if (y0 == y1)
|
||||
{
|
||||
showBar = false;
|
||||
}
|
||||
tx0 = x0;
|
||||
ty0 = yOffset + psWidget->y;
|
||||
ty0 = yOffset + psWidget->y();
|
||||
tx1 = x1;
|
||||
ty1 = y0 - 1;
|
||||
if (ty0 >= ty1)
|
||||
|
@ -443,8 +379,35 @@ void barGraphDisplayTrough(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIE
|
|||
}
|
||||
if (showTrough)
|
||||
{
|
||||
iV_ShadowBox(tx0, ty0, tx1, ty1, 0, pColours[WCOL_DARK], pColours[WCOL_LIGHT], pColours[WCOL_BKGRND]);
|
||||
iV_ShadowBox(tx0, ty0, tx1, ty1, 0, WZCOL_FORM_DARK, WZCOL_FORM_LIGHT, psBGraph->backgroundColour);
|
||||
}
|
||||
|
||||
barGraphDisplayText(psBGraph, x0, tx1, ty1, pColours);
|
||||
barGraphDisplayText(psBGraph, x0, tx1, ty1);
|
||||
}
|
||||
|
||||
void W_BARGRAPH::display(int xOffset, int yOffset)
|
||||
{
|
||||
if (displayFunction != NULL)
|
||||
{
|
||||
displayFunction(this, xOffset, yOffset);
|
||||
return;
|
||||
}
|
||||
|
||||
if (style & WBAR_TROUGH)
|
||||
{
|
||||
barGraphDisplayTrough(this, xOffset, yOffset);
|
||||
}
|
||||
else if (style & WBAR_DOUBLE)
|
||||
{
|
||||
barGraphDisplayDouble(this, xOffset, yOffset);
|
||||
}
|
||||
else
|
||||
{
|
||||
barGraphDisplay(this, xOffset, yOffset);
|
||||
}
|
||||
}
|
||||
|
||||
void W_BARGRAPH::setTip(QString string)
|
||||
{
|
||||
pTip = string;
|
||||
}
|
||||
|
|
|
@ -27,12 +27,20 @@
|
|||
#include "widget.h"
|
||||
|
||||
|
||||
struct W_BARGRAPH : public WIDGET
|
||||
class W_BARGRAPH : public WIDGET
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
W_BARGRAPH(W_BARINIT const *init);
|
||||
|
||||
void highlight(W_CONTEXT *psContext);
|
||||
void highlightLost(W_CONTEXT *);
|
||||
void highlightLost();
|
||||
void display(int xOffset, int yOffset);
|
||||
|
||||
void setTip(QString string);
|
||||
|
||||
void setBackgroundColour(PIELIGHT colour) { backgroundColour = colour; }
|
||||
|
||||
WBAR_ORIENTATION barPos; // Orientation of the bar on the widget
|
||||
UWORD majorSize; // Percentage of the main bar that is filled
|
||||
|
@ -45,23 +53,14 @@ struct W_BARGRAPH : public WIDGET
|
|||
PIELIGHT majorCol; // Colour for the major bar
|
||||
PIELIGHT minorCol; // Colour for the minor bar
|
||||
PIELIGHT textCol; // Colour for the text on the bar.
|
||||
const char *pTip; // The tool tip for the graph
|
||||
QString pTip; // The tool tip for the graph
|
||||
QString text; // Text on the bar.
|
||||
|
||||
//private:
|
||||
PIELIGHT backgroundColour;
|
||||
};
|
||||
|
||||
/* Create a barGraph widget data structure */
|
||||
extern W_BARGRAPH *barGraphCreate(const W_BARINIT *psInit);
|
||||
|
||||
/* Free the memory used by a barGraph */
|
||||
extern void barGraphFree(W_BARGRAPH *psWidget);
|
||||
|
||||
/* The bar graph display function */
|
||||
extern void barGraphDisplay(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
|
||||
/* The double bar graph display function */
|
||||
extern void barGraphDisplayDouble(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
|
||||
/* The trough bar graph display function */
|
||||
extern void barGraphDisplayTrough(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
void barGraphDisplayTrough(WIDGET* psWidget, UDWORD xOffset, UDWORD yOffset);
|
||||
|
||||
#endif // __INCLUDED_LIB_WIDGET_BAR_H__
|
||||
|
|
|
@ -32,12 +32,6 @@
|
|||
#include "lib/gamelib/gtime.h"
|
||||
|
||||
|
||||
/* Initialise the button module */
|
||||
bool buttonStartUp(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
W_BUTINIT::W_BUTINIT()
|
||||
: pText(NULL)
|
||||
, pTip(NULL)
|
||||
|
@ -46,197 +40,103 @@ W_BUTINIT::W_BUTINIT()
|
|||
|
||||
W_BUTTON::W_BUTTON(W_BUTINIT const *init)
|
||||
: WIDGET(init, WIDG_BUTTON)
|
||||
, pText(init->pText)
|
||||
, pTip(init->pTip)
|
||||
, state(WBUT_PLAIN)
|
||||
, pText(QString::fromUtf8(init->pText))
|
||||
, pTip(QString::fromUtf8(init->pTip))
|
||||
, HilightAudioID(WidgGetHilightAudioID())
|
||||
, ClickedAudioID(WidgGetClickedAudioID())
|
||||
, AudioCallback(WidgGetAudioCallback())
|
||||
, FontID(init->FontID)
|
||||
{
|
||||
if (display == NULL)
|
||||
{
|
||||
display = buttonDisplay;
|
||||
}
|
||||
|
||||
buttonInitialise(this);
|
||||
ASSERT((init->style & ~(WBUT_PLAIN | WIDG_HIDDEN | WBUT_NOPRIMARY | WBUT_SECONDARY | WBUT_TXTCENTRE)) == 0, "unknown button style");
|
||||
}
|
||||
|
||||
/* Create a button widget data structure */
|
||||
W_BUTTON *buttonCreate(const W_BUTINIT *psInit)
|
||||
W_BUTTON::W_BUTTON(WIDGET *parent)
|
||||
: WIDGET(parent, WIDG_BUTTON)
|
||||
, state(WBUT_PLAIN)
|
||||
, HilightAudioID(WidgGetHilightAudioID())
|
||||
, ClickedAudioID(WidgGetClickedAudioID())
|
||||
, AudioCallback(WidgGetAudioCallback())
|
||||
, FontID(font_regular)
|
||||
{}
|
||||
|
||||
unsigned W_BUTTON::getState()
|
||||
{
|
||||
if (psInit->style & ~(WBUT_PLAIN | WIDG_HIDDEN | WFORM_NOCLICKMOVE
|
||||
| WBUT_NOPRIMARY | WBUT_SECONDARY | WBUT_TXTCENTRE))
|
||||
{
|
||||
ASSERT(!"unknown button style", "buttonCreate: unknown button style");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Allocate the required memory */
|
||||
W_BUTTON *psWidget = new W_BUTTON(psInit);
|
||||
if (psWidget == NULL)
|
||||
{
|
||||
debug(LOG_FATAL, "buttonCreate: Out of memory");
|
||||
abort();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return psWidget;
|
||||
return state & (WBUT_DISABLE | WBUT_LOCK | WBUT_CLICKLOCK | WBUT_FLASH | WBUT_DOWN | WBUT_HIGHLIGHT);
|
||||
}
|
||||
|
||||
|
||||
/* Free the memory used by a button */
|
||||
void buttonFree(W_BUTTON *psWidget)
|
||||
void W_BUTTON::setFlash(bool enable)
|
||||
{
|
||||
ASSERT(psWidget != NULL,
|
||||
"buttonFree: invalid button pointer");
|
||||
|
||||
delete psWidget;
|
||||
}
|
||||
|
||||
|
||||
/* Initialise a button widget before it is run */
|
||||
void buttonInitialise(W_BUTTON *psWidget)
|
||||
{
|
||||
ASSERT(psWidget != NULL,
|
||||
"buttonDisplay: Invalid widget pointer");
|
||||
|
||||
psWidget->state = WBUTS_NORMAL;
|
||||
}
|
||||
|
||||
|
||||
/* Get a button's state */
|
||||
UDWORD buttonGetState(W_BUTTON *psButton)
|
||||
{
|
||||
UDWORD State = 0;
|
||||
|
||||
if (psButton->state & WBUTS_GREY)
|
||||
if (enable)
|
||||
{
|
||||
State |= WBUT_DISABLE;
|
||||
}
|
||||
|
||||
if (psButton->state & WBUTS_LOCKED)
|
||||
{
|
||||
State |= WBUT_LOCK;
|
||||
}
|
||||
|
||||
if (psButton->state & WBUTS_CLICKLOCK)
|
||||
{
|
||||
State |= WBUT_CLICKLOCK;
|
||||
}
|
||||
|
||||
if (psButton->state & WBUTS_FLASH)
|
||||
{
|
||||
State |= WBUT_FLASH;
|
||||
}
|
||||
|
||||
return State;
|
||||
}
|
||||
|
||||
|
||||
void buttonSetFlash(W_BUTTON *psButton)
|
||||
{
|
||||
psButton->state |= WBUTS_FLASH;
|
||||
}
|
||||
|
||||
|
||||
void buttonClearFlash(W_BUTTON *psButton)
|
||||
{
|
||||
psButton->state &= ~WBUTS_FLASH;
|
||||
psButton->state &= ~WBUTS_FLASHON;
|
||||
}
|
||||
|
||||
|
||||
/* Set a button's state */
|
||||
void buttonSetState(W_BUTTON *psButton, UDWORD state)
|
||||
{
|
||||
ASSERT(!((state & WBUT_LOCK) && (state & WBUT_CLICKLOCK)), "Cannot have both WBUT_LOCK and WBUT_CLICKLOCK");
|
||||
|
||||
if (state & WBUT_DISABLE)
|
||||
{
|
||||
psButton->state |= WBUTS_GREY;
|
||||
state |= WBUT_FLASH;
|
||||
}
|
||||
else
|
||||
{
|
||||
psButton->state &= ~WBUTS_GREY;
|
||||
}
|
||||
if (state & WBUT_LOCK)
|
||||
{
|
||||
psButton->state |= WBUTS_LOCKED;
|
||||
}
|
||||
else
|
||||
{
|
||||
psButton->state &= ~WBUTS_LOCKED;
|
||||
}
|
||||
if (state & WBUT_CLICKLOCK)
|
||||
{
|
||||
psButton->state |= WBUTS_CLICKLOCK;
|
||||
}
|
||||
else
|
||||
{
|
||||
psButton->state &= ~WBUTS_CLICKLOCK;
|
||||
state &= ~WBUT_FLASH;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Run a button widget */
|
||||
void W_BUTTON::run(W_CONTEXT *)
|
||||
void W_BUTTON::setState(unsigned newState)
|
||||
{
|
||||
W_BUTTON *psButton = this;
|
||||
if (psButton->state & WBUTS_FLASH)
|
||||
{
|
||||
if (((realTime / 250) % 2) == 0)
|
||||
{
|
||||
psButton->state &= ~WBUTS_FLASHON;
|
||||
}
|
||||
else
|
||||
{
|
||||
psButton->state |= WBUTS_FLASHON;
|
||||
}
|
||||
}
|
||||
ASSERT(!((newState & WBUT_LOCK) && (newState & WBUT_CLICKLOCK)), "Cannot have both WBUT_LOCK and WBUT_CLICKLOCK");
|
||||
|
||||
unsigned mask = WBUT_DISABLE | WBUT_LOCK | WBUT_CLICKLOCK;
|
||||
state = (state & ~mask) | (newState & mask);
|
||||
}
|
||||
|
||||
QString W_BUTTON::getString() const
|
||||
{
|
||||
return pText;
|
||||
}
|
||||
|
||||
void W_BUTTON::setString(QString string)
|
||||
{
|
||||
pText = string;
|
||||
}
|
||||
|
||||
void W_BUTTON::setTip(QString string)
|
||||
{
|
||||
pTip = string;
|
||||
}
|
||||
|
||||
/* Respond to a mouse click */
|
||||
void W_BUTTON::clicked(W_CONTEXT *, WIDGET_KEY key)
|
||||
{
|
||||
W_BUTTON *psWidget = this;
|
||||
/* Can't click a button if it is disabled or locked down */
|
||||
if (!(psWidget->state & (WBUTS_GREY | WBUTS_LOCKED)))
|
||||
if ((state & (WBUT_DISABLE | WBUT_LOCK)) == 0)
|
||||
{
|
||||
// Check this is the correct key
|
||||
if ((!(psWidget->style & WBUT_NOPRIMARY) && key == WKEY_PRIMARY) ||
|
||||
((psWidget->style & WBUT_SECONDARY) && key == WKEY_SECONDARY))
|
||||
if ((!(style & WBUT_NOPRIMARY) && key == WKEY_PRIMARY) ||
|
||||
((style & WBUT_SECONDARY) && key == WKEY_SECONDARY))
|
||||
{
|
||||
if (psWidget->AudioCallback)
|
||||
if (AudioCallback)
|
||||
{
|
||||
psWidget->AudioCallback(psWidget->ClickedAudioID);
|
||||
AudioCallback(ClickedAudioID);
|
||||
}
|
||||
psWidget->state &= ~WBUTS_FLASH; // Stop it flashing
|
||||
psWidget->state &= ~WBUTS_FLASHON;
|
||||
psWidget->state |= WBUTS_DOWN;
|
||||
state &= ~WBUT_FLASH; // Stop it flashing
|
||||
state |= WBUT_DOWN;
|
||||
}
|
||||
}
|
||||
|
||||
/* Kill the tip if there is one */
|
||||
if (psWidget->pTip)
|
||||
if (!pTip.isEmpty())
|
||||
{
|
||||
tipStop((WIDGET *)psWidget);
|
||||
tipStop(this);
|
||||
}
|
||||
}
|
||||
|
||||
/* Respond to a mouse button up */
|
||||
void W_BUTTON::released(W_CONTEXT *psContext, WIDGET_KEY key)
|
||||
void W_BUTTON::released(W_CONTEXT *, WIDGET_KEY key)
|
||||
{
|
||||
W_SCREEN *psScreen = psContext->psScreen;
|
||||
W_BUTTON *psWidget = this;
|
||||
if (psWidget->state & WBUTS_DOWN)
|
||||
if (state & WBUT_DOWN)
|
||||
{
|
||||
// Check this is the correct key
|
||||
if ((!(psWidget->style & WBUT_NOPRIMARY) && key == WKEY_PRIMARY) ||
|
||||
((psWidget->style & WBUT_SECONDARY) && key == WKEY_SECONDARY))
|
||||
if ((!(style & WBUT_NOPRIMARY) && key == WKEY_PRIMARY) ||
|
||||
((style & WBUT_SECONDARY) && key == WKEY_SECONDARY))
|
||||
{
|
||||
widgSetReturn(psScreen, (WIDGET *)psWidget);
|
||||
psWidget->state &= ~WBUTS_DOWN;
|
||||
emit clicked();
|
||||
screenPointer->setReturn(this);
|
||||
state &= ~WBUT_DOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -245,127 +145,112 @@ void W_BUTTON::released(W_CONTEXT *psContext, WIDGET_KEY key)
|
|||
/* Respond to a mouse moving over a button */
|
||||
void W_BUTTON::highlight(W_CONTEXT *psContext)
|
||||
{
|
||||
W_BUTTON *psWidget = this;
|
||||
psWidget->state |= WBUTS_HILITE;
|
||||
state |= WBUT_HIGHLIGHT;
|
||||
|
||||
if (psWidget->AudioCallback)
|
||||
if (AudioCallback)
|
||||
{
|
||||
psWidget->AudioCallback(psWidget->HilightAudioID);
|
||||
AudioCallback(HilightAudioID);
|
||||
}
|
||||
|
||||
/* If there is a tip string start the tool tip */
|
||||
if (psWidget->pTip)
|
||||
if (!pTip.isEmpty())
|
||||
{
|
||||
tipStart((WIDGET *)psWidget, psWidget->pTip, psContext->psScreen->TipFontID,
|
||||
psContext->psForm->aColours,
|
||||
psWidget->x + psContext->xOffset, psWidget->y + psContext->yOffset,
|
||||
psWidget->width, psWidget->height);
|
||||
tipStart(this, pTip, screenPointer->TipFontID, x() + psContext->xOffset, y() + psContext->yOffset, width(), height());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Respond to the mouse moving off a button */
|
||||
void W_BUTTON::highlightLost(W_CONTEXT *)
|
||||
void W_BUTTON::highlightLost()
|
||||
{
|
||||
W_BUTTON *psWidget = this;
|
||||
psWidget->state &= ~(WBUTS_DOWN | WBUTS_HILITE);
|
||||
if (psWidget->pTip)
|
||||
state &= ~(WBUT_DOWN | WBUT_HIGHLIGHT);
|
||||
if (!pTip.isEmpty())
|
||||
{
|
||||
tipStop((WIDGET *)psWidget);
|
||||
tipStop(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Display a button */
|
||||
void buttonDisplay(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours)
|
||||
void W_BUTTON::display(int xOffset, int yOffset)
|
||||
{
|
||||
W_BUTTON *psButton;
|
||||
SDWORD x0, y0, x1, y1, fx, fy, fw;
|
||||
|
||||
ASSERT(psWidget != NULL && pColours != NULL, "Invalid pointers");
|
||||
if (!psWidget || !pColours)
|
||||
if (displayFunction != NULL)
|
||||
{
|
||||
displayFunction(this, xOffset, yOffset);
|
||||
return;
|
||||
}
|
||||
|
||||
psButton = (W_BUTTON *)psWidget;
|
||||
int x0 = x() + xOffset;
|
||||
int y0 = y() + yOffset;
|
||||
int x1 = x0 + width();
|
||||
int y1 = y0 + height();
|
||||
|
||||
x0 = psButton->x + xOffset;
|
||||
y0 = psButton->y + yOffset;
|
||||
x1 = x0 + psButton->width;
|
||||
y1 = y0 + psButton->height;
|
||||
bool haveText = !pText.isEmpty();
|
||||
|
||||
if (psButton->state & (WBUTS_DOWN | WBUTS_LOCKED | WBUTS_CLICKLOCK))
|
||||
bool isDown = (state & (WBUT_DOWN | WBUT_LOCK | WBUT_CLICKLOCK)) != 0;
|
||||
bool isDisabled = (state & WBUT_DISABLE) != 0;
|
||||
bool isHighlight = (state & WBUT_HIGHLIGHT) != 0;
|
||||
|
||||
// Display the button.
|
||||
if (!image.isNull())
|
||||
{
|
||||
/* Display the button down */
|
||||
iV_ShadowBox(x0, y0, x1, y1, 0, pColours[WCOL_LIGHT], pColours[WCOL_DARK], pColours[WCOL_BKGRND]);
|
||||
|
||||
if (psButton->pText)
|
||||
iV_DrawImage(image, x0, y0);
|
||||
if (isDown && !imageDown.isNull())
|
||||
{
|
||||
iV_SetFont(psButton->FontID);
|
||||
iV_SetTextColour(pColours[WCOL_TEXT]);
|
||||
fw = iV_GetTextWidth(psButton->pText);
|
||||
if (psButton->style & WBUT_NOCLICKMOVE)
|
||||
{
|
||||
fx = x0 + (psButton->width - fw) / 2 + 1;
|
||||
fy = y0 + 1 + (psButton->height - iV_GetTextLineSize()) / 2 - iV_GetTextAboveBase();
|
||||
}
|
||||
else
|
||||
{
|
||||
fx = x0 + (psButton->width - fw) / 2;
|
||||
fy = y0 + (psButton->height - iV_GetTextLineSize()) / 2 - iV_GetTextAboveBase();
|
||||
}
|
||||
iV_DrawText(psButton->pText, fx, fy);
|
||||
iV_DrawImage(imageDown, x0, y0);
|
||||
}
|
||||
|
||||
if (psButton->state & WBUTS_HILITE)
|
||||
if (isDisabled && !imageDisabled.isNull())
|
||||
{
|
||||
/* Display the button hilite */
|
||||
iV_Box(x0 + 3, y0 + 3, x1 - 2, y1 - 2, pColours[WCOL_HILITE]);
|
||||
iV_DrawImage(imageDisabled, x0, y0);
|
||||
}
|
||||
}
|
||||
else if (psButton->state & WBUTS_GREY)
|
||||
{
|
||||
/* Display the disabled button */
|
||||
iV_ShadowBox(x0, y0, x1, y1, 0, pColours[WCOL_LIGHT], pColours[WCOL_LIGHT], pColours[WCOL_BKGRND]);
|
||||
|
||||
if (psButton->pText)
|
||||
if (isHighlight && !imageHighlight.isNull())
|
||||
{
|
||||
iV_SetFont(psButton->FontID);
|
||||
fw = iV_GetTextWidth(psButton->pText);
|
||||
fx = x0 + (psButton->width - fw) / 2;
|
||||
fy = y0 + (psButton->height - iV_GetTextLineSize()) / 2 - iV_GetTextAboveBase();
|
||||
iV_SetTextColour(pColours[WCOL_LIGHT]);
|
||||
iV_DrawText(psButton->pText, fx + 1, fy + 1);
|
||||
iV_SetTextColour(pColours[WCOL_DISABLE]);
|
||||
iV_DrawText(psButton->pText, fx, fy);
|
||||
}
|
||||
|
||||
if (psButton->state & WBUTS_HILITE)
|
||||
{
|
||||
/* Display the button hilite */
|
||||
iV_Box(x0 + 2, y0 + 2, x1 - 3, y1 - 3, pColours[WCOL_HILITE]);
|
||||
iV_DrawImage(imageHighlight, x0, y0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Display the button up */
|
||||
iV_ShadowBox(x0, y0, x1, y1, 0, pColours[WCOL_LIGHT], pColours[WCOL_DARK], pColours[WCOL_BKGRND]);
|
||||
|
||||
if (psButton->pText)
|
||||
iV_ShadowBox(x0, y0, x1, y1, 0, WZCOL_FORM_LIGHT, isDisabled? WZCOL_FORM_LIGHT : WZCOL_FORM_DARK, WZCOL_FORM_BACKGROUND);
|
||||
if (isHighlight)
|
||||
{
|
||||
iV_SetFont(psButton->FontID);
|
||||
iV_SetTextColour(pColours[WCOL_TEXT]);
|
||||
fw = iV_GetTextWidth(psButton->pText);
|
||||
fx = x0 + (psButton->width - fw) / 2;
|
||||
fy = y0 + (psButton->height - iV_GetTextLineSize()) / 2 - iV_GetTextAboveBase();
|
||||
iV_DrawText(psButton->pText, fx, fy);
|
||||
}
|
||||
|
||||
if (psButton->state & WBUTS_HILITE)
|
||||
{
|
||||
/* Display the button hilite */
|
||||
iV_Box(x0 + 2, y0 + 2, x1 - 3, y1 - 3, pColours[WCOL_HILITE]);
|
||||
iV_Box(x0 + 2, y0 + 2, x1 - 3, y1 - 3, WZCOL_FORM_HILITE);
|
||||
}
|
||||
}
|
||||
|
||||
if (haveText)
|
||||
{
|
||||
QByteArray textBytes = pText.toUtf8();
|
||||
|
||||
iV_SetFont(FontID);
|
||||
int fw = iV_GetTextWidth(textBytes.constData());
|
||||
int fx = x0 + (width() - fw) / 2;
|
||||
int fy = y0 + (height() - iV_GetTextLineSize()) / 2 - iV_GetTextAboveBase();
|
||||
if (isDisabled)
|
||||
{
|
||||
iV_SetTextColour(WZCOL_FORM_LIGHT);
|
||||
iV_DrawText(textBytes.constData(), fx + 1, fy + 1);
|
||||
iV_SetTextColour(WZCOL_FORM_DISABLE);
|
||||
}
|
||||
else
|
||||
{
|
||||
iV_SetTextColour(WZCOL_FORM_TEXT);
|
||||
}
|
||||
iV_DrawText(textBytes.constData(), fx, fy);
|
||||
}
|
||||
|
||||
if (isDisabled && !image.isNull() && imageDisabled.isNull())
|
||||
{
|
||||
// disabled, render something over it!
|
||||
iV_TransBoxFill(x0, y0, x0 + width(), y0 + height());
|
||||
}
|
||||
}
|
||||
|
||||
void W_BUTTON::setImages(Image image_, Image imageDown_, Image imageHighlight_, Image imageDisabled_)
|
||||
{
|
||||
image = image_;
|
||||
imageDown = imageDown_;
|
||||
imageDisabled = imageDisabled_;
|
||||
imageHighlight = imageHighlight_;
|
||||
if (!image.isNull())
|
||||
{
|
||||
setGeometry(x(), y(), image.width(), image.height());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,58 +28,48 @@
|
|||
#include "widgbase.h"
|
||||
#include "lib/ivis_opengl/textdraw.h"
|
||||
|
||||
/* Button states */
|
||||
#define WBUTS_NORMAL 0x0000
|
||||
#define WBUTS_DOWN 0x0001 // Button is down
|
||||
#define WBUTS_GREY 0x0002 // Button is disabled
|
||||
#define WBUTS_HILITE 0x0004 // Button is hilited
|
||||
#define WBUTS_LOCKED 0x0008 // Button is locked down
|
||||
#define WBUTS_CLICKLOCK 0x0010 // Button is locked but clickable
|
||||
#define WBUTS_FLASH 0x0020 // Button flashing is enabled
|
||||
#define WBUTS_FLASHON 0x0040 // Button is flashing
|
||||
|
||||
|
||||
struct W_BUTTON : public WIDGET
|
||||
class W_BUTTON : public WIDGET
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
W_BUTTON(W_BUTINIT const *init);
|
||||
W_BUTTON(WIDGET *parent);
|
||||
|
||||
void clicked(W_CONTEXT *psContext, WIDGET_KEY key);
|
||||
void released(W_CONTEXT *psContext, WIDGET_KEY key);
|
||||
void highlight(W_CONTEXT *psContext);
|
||||
void highlightLost(W_CONTEXT *psContext);
|
||||
void run(W_CONTEXT *psContext);
|
||||
void highlightLost();
|
||||
void display(int xOffset, int yOffset);
|
||||
|
||||
unsigned getState();
|
||||
void setState(unsigned state);
|
||||
void setFlash(bool enable);
|
||||
QString getString() const;
|
||||
void setString(QString string);
|
||||
void setTip(QString string);
|
||||
|
||||
void setImages(Image image, Image imageDown, Image imageHighlight, Image imageDisabled = Image());
|
||||
|
||||
void setString(char const *stringUtf8) { WIDGET::setString(stringUtf8); } // Unhide the WIDGET::setString(char const *) function...
|
||||
void setTip(char const *stringUtf8) { WIDGET::setTip(stringUtf8); } // Unhide the WIDGET::setTip(char const *) function...
|
||||
|
||||
signals:
|
||||
void clicked();
|
||||
|
||||
public:
|
||||
UDWORD state; // The current button state
|
||||
const char *pText; // The text for the button
|
||||
const char *pTip; // The tool tip for the button
|
||||
QString pText; // The text for the button
|
||||
Image image; ///< The image for the button.
|
||||
Image imageDown; ///< The image for the button, when down. Is overlaid over image.
|
||||
Image imageDisabled; ///< The image for the button, when disabled. Is overlaid over image.
|
||||
Image imageHighlight; ///< The image for the button, when highlighted. Is overlaid over image.
|
||||
QString pTip; // The tool tip for the button
|
||||
SWORD HilightAudioID; // Audio ID for form clicked sound
|
||||
SWORD ClickedAudioID; // Audio ID for form hilighted sound
|
||||
WIDGET_AUDIOCALLBACK AudioCallback; // Pointer to audio callback function
|
||||
enum iV_fonts FontID;
|
||||
iV_fonts FontID;
|
||||
};
|
||||
|
||||
/* Initialise the button module */
|
||||
extern bool buttonStartUp(void);
|
||||
|
||||
/* Create a button widget data structure */
|
||||
extern W_BUTTON *buttonCreate(const W_BUTINIT *psInit);
|
||||
|
||||
/* Free the memory used by a button */
|
||||
extern void buttonFree(W_BUTTON *psWidget);
|
||||
|
||||
/* Initialise a button widget before running it */
|
||||
extern void buttonInitialise(W_BUTTON *psWidget);
|
||||
|
||||
/* Get a button's state */
|
||||
extern UDWORD buttonGetState(W_BUTTON *psButton);
|
||||
|
||||
/* Set a button's state */
|
||||
extern void buttonSetState(W_BUTTON *psWidget, UDWORD state);
|
||||
|
||||
extern void buttonSetFlash(W_BUTTON *psButton);
|
||||
extern void buttonClearFlash(W_BUTTON *psButton);
|
||||
|
||||
/* The button display function */
|
||||
extern void buttonDisplay(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
|
||||
#endif // __INCLUDED_LIB_WIDGET_BUTTON_H__
|
||||
|
|
|
@ -55,18 +55,21 @@ W_EDBINIT::W_EDBINIT()
|
|||
: pText(NULL)
|
||||
, FontID(font_regular)
|
||||
, pBoxDisplay(NULL)
|
||||
, pFontDisplay(NULL)
|
||||
{}
|
||||
|
||||
W_EDITBOX::W_EDITBOX(W_EDBINIT const *init)
|
||||
: WIDGET(init, WIDG_EDITBOX)
|
||||
, state(WEDBS_FIXED)
|
||||
, FontID(init->FontID)
|
||||
, blinkOffset(wzGetTicks())
|
||||
, printStart(0)
|
||||
, pBoxDisplay(init->pBoxDisplay)
|
||||
, pFontDisplay(init->pFontDisplay)
|
||||
, HilightAudioID(WidgGetHilightAudioID())
|
||||
, ClickedAudioID(WidgGetClickedAudioID())
|
||||
, AudioCallback(WidgGetAudioCallback())
|
||||
, boxColourFirst(WZCOL_FORM_DARK)
|
||||
, boxColourSecond(WZCOL_FORM_LIGHT)
|
||||
, boxColourBackground(WZCOL_FORM_BACKGROUND)
|
||||
{
|
||||
char const *text = init->pText;
|
||||
if (!text)
|
||||
|
@ -75,37 +78,24 @@ W_EDITBOX::W_EDITBOX(W_EDBINIT const *init)
|
|||
}
|
||||
aText = QString::fromUtf8(text);
|
||||
|
||||
if (display == NULL)
|
||||
{
|
||||
display = editBoxDisplay;
|
||||
}
|
||||
|
||||
initialise();
|
||||
|
||||
ASSERT((init->style & ~(WEDB_PLAIN | WIDG_HIDDEN)) == 0, "Unknown edit box style");
|
||||
}
|
||||
|
||||
/* Create an edit box widget data structure */
|
||||
W_EDITBOX *editBoxCreate(const W_EDBINIT *psInit)
|
||||
{
|
||||
if (psInit->style & ~(WEDB_PLAIN | WIDG_HIDDEN))
|
||||
{
|
||||
ASSERT(false, "Unknown edit box style");
|
||||
return NULL;
|
||||
}
|
||||
W_EDITBOX::W_EDITBOX(WIDGET* parent)
|
||||
: WIDGET(parent)
|
||||
, state(WEDBS_FIXED)
|
||||
, FontID(font_regular)
|
||||
, pBoxDisplay(nullptr)
|
||||
, HilightAudioID(WidgGetHilightAudioID())
|
||||
, ClickedAudioID(WidgGetClickedAudioID())
|
||||
, AudioCallback(WidgGetAudioCallback())
|
||||
, boxColourFirst(WZCOL_FORM_DARK)
|
||||
, boxColourSecond(WZCOL_FORM_LIGHT)
|
||||
, boxColourBackground(WZCOL_FORM_BACKGROUND)
|
||||
{}
|
||||
|
||||
/* Allocate the required memory */
|
||||
W_EDITBOX *psWidget = new W_EDITBOX(psInit);
|
||||
if (psWidget == NULL)
|
||||
{
|
||||
debug(LOG_FATAL, "editBoxCreate: Out of memory");
|
||||
abort();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return psWidget;
|
||||
}
|
||||
|
||||
|
||||
/* Initialise an edit box widget */
|
||||
void W_EDITBOX::initialise()
|
||||
{
|
||||
state = WEDBS_FIXED;
|
||||
|
@ -198,7 +188,7 @@ void W_EDITBOX::fitStringStart()
|
|||
{
|
||||
int pixelWidth = iV_GetTextWidth(tmp.toUtf8().constData());
|
||||
|
||||
if (pixelWidth <= width - (WEDB_XGAP * 2 + WEDB_CURSORSIZE))
|
||||
if (pixelWidth <= width() - (WEDB_XGAP * 2 + WEDB_CURSORSIZE))
|
||||
{
|
||||
printChars = tmp.length();
|
||||
printWidth = pixelWidth;
|
||||
|
@ -224,7 +214,7 @@ void W_EDITBOX::fitStringEnd()
|
|||
{
|
||||
int pixelWidth = iV_GetTextWidth(tmp.toUtf8().constData());
|
||||
|
||||
if (pixelWidth <= width - (WEDB_XGAP * 2 + WEDB_CURSORSIZE))
|
||||
if (pixelWidth <= width() - (WEDB_XGAP * 2 + WEDB_CURSORSIZE))
|
||||
{
|
||||
printChars = tmp.length();
|
||||
printWidth = pixelWidth;
|
||||
|
@ -285,9 +275,9 @@ void W_EDITBOX::run(W_CONTEXT *psContext)
|
|||
/* If there is a mouse click outside of the edit box - stop editing */
|
||||
int mx = psContext->mx;
|
||||
int my = psContext->my;
|
||||
if (mousePressed(MOUSE_LMB) && (mx < x || mx > x + width || my < y || my > y + height))
|
||||
if (mousePressed(MOUSE_LMB) && !geometry().contains(mx, my))
|
||||
{
|
||||
screenClearFocus(psContext->psScreen);
|
||||
screenPointer->setFocus(nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -400,8 +390,7 @@ void W_EDITBOX::run(W_CONTEXT *psContext)
|
|||
case INPBUF_CR :
|
||||
case KEY_KPENTER: // either normal return key || keypad enter
|
||||
/* Finish editing */
|
||||
focusLost(psContext->psScreen);
|
||||
screenClearFocus(psContext->psScreen);
|
||||
screenPointer->setFocus(nullptr);
|
||||
debug(LOG_INPUT, "EditBox cursor return");
|
||||
return;
|
||||
break;
|
||||
|
@ -461,11 +450,15 @@ void W_EDITBOX::run(W_CONTEXT *psContext)
|
|||
state = (state & ~WEDBS_MASK) | editState;
|
||||
}
|
||||
|
||||
QString W_EDITBOX::getString() const
|
||||
{
|
||||
return aText;
|
||||
}
|
||||
|
||||
/* Set the current string for the edit box */
|
||||
void W_EDITBOX::setString(char const *utf8)
|
||||
void W_EDITBOX::setString(QString string)
|
||||
{
|
||||
aText = QString::fromUtf8(utf8);
|
||||
aText = string;
|
||||
initialise();
|
||||
}
|
||||
|
||||
|
@ -480,7 +473,7 @@ void W_EDITBOX::clicked(W_CONTEXT *psContext, WIDGET_KEY)
|
|||
|
||||
// Set cursor position to the click location.
|
||||
iV_SetFont(FontID);
|
||||
setCursorPosPixels(psContext->mx - x);
|
||||
setCursorPosPixels(psContext->mx - x());
|
||||
|
||||
// Cursor should be visible instantly.
|
||||
blinkOffset = wzGetTicks();
|
||||
|
@ -502,13 +495,13 @@ void W_EDITBOX::clicked(W_CONTEXT *psContext, WIDGET_KEY)
|
|||
inputClearBuffer();
|
||||
|
||||
/* Tell the form that the edit box has focus */
|
||||
screenSetFocus(psContext->psScreen, this);
|
||||
screenPointer->setFocus(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Respond to loss of focus */
|
||||
void W_EDITBOX::focusLost(W_SCREEN *psScreen)
|
||||
void W_EDITBOX::focusLost()
|
||||
{
|
||||
ASSERT(!(state & WEDBS_DISABLE), "editBoxFocusLost: disabled edit box");
|
||||
|
||||
|
@ -517,7 +510,7 @@ void W_EDITBOX::focusLost(W_SCREEN *psScreen)
|
|||
printStart = 0;
|
||||
fitStringStart();
|
||||
|
||||
widgSetReturn(psScreen, this);
|
||||
screenPointer->setReturn(this);
|
||||
}
|
||||
|
||||
|
||||
|
@ -540,7 +533,7 @@ void W_EDITBOX::highlight(W_CONTEXT *)
|
|||
|
||||
|
||||
/* Respond to the mouse moving off an edit box */
|
||||
void W_EDITBOX::highlightLost(W_CONTEXT *)
|
||||
void W_EDITBOX::highlightLost()
|
||||
{
|
||||
W_EDITBOX *psWidget = this;
|
||||
if (psWidget->state & WEDBS_DISABLE)
|
||||
|
@ -551,105 +544,96 @@ void W_EDITBOX::highlightLost(W_CONTEXT *)
|
|||
psWidget->state = psWidget->state & WEDBS_MASK;
|
||||
}
|
||||
|
||||
|
||||
/* The edit box display function */
|
||||
void editBoxDisplay(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours)
|
||||
void W_EDITBOX::setBoxColours(PIELIGHT first, PIELIGHT second, PIELIGHT background)
|
||||
{
|
||||
W_EDITBOX *psEdBox;
|
||||
SDWORD x0, y0, x1, y1, fx, fy, cx, cy;
|
||||
enum iV_fonts CurrFontID;
|
||||
boxColourFirst = first;
|
||||
boxColourSecond = second;
|
||||
boxColourBackground = background;
|
||||
}
|
||||
|
||||
#if CURSOR_BLINK
|
||||
bool blink;
|
||||
#endif
|
||||
|
||||
psEdBox = (W_EDITBOX *)psWidget;
|
||||
CurrFontID = psEdBox->FontID;
|
||||
|
||||
x0 = psEdBox->x + xOffset;
|
||||
y0 = psEdBox->y + yOffset;
|
||||
x1 = x0 + psEdBox->width;
|
||||
y1 = y0 + psEdBox->height;
|
||||
|
||||
if (psEdBox->pBoxDisplay)
|
||||
void W_EDITBOX::display(int xOffset, int yOffset)
|
||||
{
|
||||
if (displayFunction != NULL)
|
||||
{
|
||||
psEdBox->pBoxDisplay((WIDGET *)psEdBox, xOffset, yOffset, pColours);
|
||||
displayFunction(this, xOffset, yOffset);
|
||||
return;
|
||||
}
|
||||
|
||||
int x0 = x() + xOffset;
|
||||
int y0 = y() + yOffset;
|
||||
int x1 = x0 + width();
|
||||
int y1 = y0 + height();
|
||||
|
||||
if (pBoxDisplay != NULL)
|
||||
{
|
||||
pBoxDisplay(this, xOffset, yOffset);
|
||||
}
|
||||
else
|
||||
{
|
||||
iV_ShadowBox(x0, y0, x1, y1, 0, pColours[WCOL_DARK], pColours[WCOL_LIGHT], pColours[WCOL_BKGRND]);
|
||||
iV_ShadowBox(x0, y0, x1, y1, 0, boxColourFirst, boxColourSecond, boxColourBackground);
|
||||
}
|
||||
|
||||
fx = x0 + WEDB_XGAP;// + (psEdBox->width - fw) / 2;
|
||||
int fx = x0 + WEDB_XGAP;// + (psEdBox->width - fw) / 2;
|
||||
|
||||
iV_SetFont(CurrFontID);
|
||||
iV_SetTextColour(pColours[WCOL_TEXT]);
|
||||
iV_SetFont(FontID);
|
||||
iV_SetTextColour(WZCOL_FORM_TEXT);
|
||||
|
||||
fy = y0 + (psEdBox->height - iV_GetTextLineSize()) / 2 - iV_GetTextAboveBase();
|
||||
int fy = y0 + (height() - iV_GetTextLineSize()) / 2 - iV_GetTextAboveBase();
|
||||
|
||||
/* If there is more text than will fit into the box, display the bit with the cursor in it */
|
||||
QString tmp = psEdBox->aText;
|
||||
tmp.remove(0, psEdBox->printStart); // Erase anything there isn't room to display.
|
||||
tmp.remove(psEdBox->printChars, tmp.length());
|
||||
QString tmp = aText;
|
||||
tmp.remove(0, printStart); // Erase anything there isn't room to display.
|
||||
tmp.remove(printChars, tmp.length());
|
||||
|
||||
iV_DrawText(tmp.toUtf8().constData(), fx, fy);
|
||||
|
||||
// Display the cursor if editing
|
||||
#if CURSOR_BLINK
|
||||
blink = !(((wzGetTicks() - psEdBox->blinkOffset) / WEDB_BLINKRATE) % 2);
|
||||
if ((psEdBox->state & WEDBS_MASK) == WEDBS_INSERT && blink)
|
||||
bool blink = !(((wzGetTicks() - blinkOffset) / WEDB_BLINKRATE) % 2);
|
||||
if ((state & WEDBS_MASK) == WEDBS_INSERT && blink)
|
||||
#else
|
||||
if ((psEdBox->state & WEDBS_MASK) == WEDBS_INSERT)
|
||||
if ((state & WEDBS_MASK) == WEDBS_INSERT)
|
||||
#endif
|
||||
{
|
||||
// insert mode
|
||||
QString tmp = psEdBox->aText;
|
||||
tmp.remove(psEdBox->insPos, tmp.length()); // Erase from the cursor on, to find where the cursor should be.
|
||||
tmp.remove(0, psEdBox->printStart);
|
||||
QString tmp = aText;
|
||||
tmp.remove(insPos, tmp.length()); // Erase from the cursor on, to find where the cursor should be.
|
||||
tmp.remove(0, printStart);
|
||||
|
||||
cx = x0 + WEDB_XGAP + iV_GetTextWidth(tmp.toUtf8().constData());
|
||||
int cx = x0 + WEDB_XGAP + iV_GetTextWidth(tmp.toUtf8().constData());
|
||||
cx += iV_GetTextWidth("-");
|
||||
cy = fy;
|
||||
iV_Line(cx, cy + iV_GetTextAboveBase(), cx, cy - iV_GetTextBelowBase(), pColours[WCOL_CURSOR]);
|
||||
int cy = fy;
|
||||
iV_Line(cx, cy + iV_GetTextAboveBase(), cx, cy - iV_GetTextBelowBase(), WZCOL_FORM_CURSOR);
|
||||
}
|
||||
#if CURSOR_BLINK
|
||||
else if ((psEdBox->state & WEDBS_MASK) == WEDBS_OVER && blink)
|
||||
else if ((state & WEDBS_MASK) == WEDBS_OVER && blink)
|
||||
#else
|
||||
else if ((psEdBox->state & WEDBS_MASK) == WEDBS_OVER)
|
||||
else if ((state & WEDBS_MASK) == WEDBS_OVER)
|
||||
#endif
|
||||
{
|
||||
// overwrite mode
|
||||
QString tmp = psEdBox->aText;
|
||||
tmp.remove(psEdBox->insPos, tmp.length()); // Erase from the cursor on, to find where the cursor should be.
|
||||
tmp.remove(0, psEdBox->printStart);
|
||||
QString tmp = aText;
|
||||
tmp.remove(insPos, tmp.length()); // Erase from the cursor on, to find where the cursor should be.
|
||||
tmp.remove(0, printStart);
|
||||
|
||||
cx = x0 + WEDB_XGAP + iV_GetTextWidth(tmp.toUtf8().constData());
|
||||
cy = fy;
|
||||
iV_Line(cx, cy, cx + WEDB_CURSORSIZE, cy, pColours[WCOL_CURSOR]);
|
||||
int cx = x0 + WEDB_XGAP + iV_GetTextWidth(tmp.toUtf8().constData());
|
||||
int cy = fy;
|
||||
iV_Line(cx, cy, cx + WEDB_CURSORSIZE, cy, WZCOL_FORM_CURSOR);
|
||||
}
|
||||
|
||||
if (psEdBox->pBoxDisplay == NULL)
|
||||
if (pBoxDisplay == NULL)
|
||||
{
|
||||
if (psEdBox->state & WEDBS_HILITE)
|
||||
if ((state & WEDBS_HILITE) != 0)
|
||||
{
|
||||
/* Display the button hilite */
|
||||
iV_Box(x0 - 2, y0 - 2, x1 + 2, y1 + 2, pColours[WCOL_HILITE]);
|
||||
iV_Box(x0 - 2, y0 - 2, x1 + 2, y1 + 2, WZCOL_FORM_HILITE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Set an edit box'sstate */
|
||||
void editBoxSetState(W_EDITBOX *psEditBox, UDWORD state)
|
||||
void W_EDITBOX::setState(unsigned newState)
|
||||
{
|
||||
if (state & WEDBS_DISABLE)
|
||||
{
|
||||
psEditBox->state |= WEDBS_DISABLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
psEditBox->state &= ~WEDBS_DISABLE;
|
||||
}
|
||||
|
||||
unsigned mask = WEDBS_DISABLE;
|
||||
state = (state & ~mask) | (newState & mask);
|
||||
}
|
||||
|
|
|
@ -38,18 +38,26 @@
|
|||
#define WEDBS_DISABLE 0x0020 // disable button from selection
|
||||
|
||||
|
||||
struct W_EDITBOX : public WIDGET
|
||||
class W_EDITBOX : public WIDGET
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
W_EDITBOX(W_EDBINIT const *init);
|
||||
W_EDITBOX(WIDGET *parent);
|
||||
|
||||
void initialise(); // Moves the cursor to the end.
|
||||
void setString(char const *utf8);
|
||||
|
||||
void clicked(W_CONTEXT *psContext, WIDGET_KEY key);
|
||||
void clicked(W_CONTEXT *psContext, WIDGET_KEY key = WKEY_PRIMARY);
|
||||
void highlight(W_CONTEXT *psContext);
|
||||
void highlightLost(W_CONTEXT *psContext);
|
||||
void focusLost(W_SCREEN *psScreen);
|
||||
void highlightLost();
|
||||
void focusLost();
|
||||
void run(W_CONTEXT *psContext);
|
||||
void display(int xOffset, int yOffset);
|
||||
|
||||
void setState(unsigned state);
|
||||
QString getString() const;
|
||||
void setString(QString string);
|
||||
|
||||
void setBoxColours(PIELIGHT first, PIELIGHT second, PIELIGHT background);
|
||||
|
||||
UDWORD state; // The current edit box state
|
||||
QString aText; // The text in the edit box
|
||||
|
@ -60,12 +68,12 @@ struct W_EDITBOX : public WIDGET
|
|||
int printChars; // The number of characters appearing in the box
|
||||
int printWidth; // The pixel width of the characters in the box
|
||||
WIDGET_DISPLAY pBoxDisplay; // Optional callback to display the edit box background.
|
||||
FONT_DISPLAY pFontDisplay; // Optional callback to display a string.
|
||||
SWORD HilightAudioID; // Audio ID for form clicked sound
|
||||
SWORD ClickedAudioID; // Audio ID for form hilighted sound
|
||||
WIDGET_AUDIOCALLBACK AudioCallback; // Pointer to audio callback function
|
||||
|
||||
private:
|
||||
void initialise(); // Moves the cursor to the end.
|
||||
void delCharRight();
|
||||
void delCharLeft();
|
||||
void insertChar(QChar ch);
|
||||
|
@ -73,15 +81,8 @@ private:
|
|||
void fitStringStart(); // Calculate how much of the start of a string can fit into the edit box
|
||||
void fitStringEnd();
|
||||
void setCursorPosPixels(int xPos);
|
||||
|
||||
PIELIGHT boxColourFirst, boxColourSecond, boxColourBackground;
|
||||
};
|
||||
|
||||
/* Create an edit box widget data structure */
|
||||
extern W_EDITBOX *editBoxCreate(const W_EDBINIT *psInit);
|
||||
|
||||
/* The edit box display function */
|
||||
extern void editBoxDisplay(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
|
||||
/* set state of edit box */
|
||||
extern void editBoxSetState(W_EDITBOX *psEditBox, UDWORD state);
|
||||
|
||||
#endif // __INCLUDED_LIB_WIDGET_EDITBOX_H__
|
||||
|
|
1613
lib/widget/form.cpp
1613
lib/widget/form.cpp
File diff suppressed because it is too large
Load Diff
|
@ -28,143 +28,52 @@
|
|||
|
||||
|
||||
/* The standard form */
|
||||
struct W_FORM : public WIDGET
|
||||
class W_FORM : public WIDGET
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
W_FORM(W_FORMINIT const *init);
|
||||
W_FORM(WIDGET *parent);
|
||||
|
||||
void clicked(W_CONTEXT *psContext, WIDGET_KEY key);
|
||||
void highlightLost();
|
||||
void display(int xOffset, int yOffset);
|
||||
|
||||
bool disableChildren; ///< Disable all child widgets if true
|
||||
};
|
||||
|
||||
/* The clickable form data structure */
|
||||
class W_CLICKFORM : public W_FORM
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
W_CLICKFORM(W_FORMINIT const *init);
|
||||
W_CLICKFORM(WIDGET *parent);
|
||||
|
||||
void clicked(W_CONTEXT *psContext, WIDGET_KEY key);
|
||||
void released(W_CONTEXT *psContext, WIDGET_KEY key);
|
||||
void highlight(W_CONTEXT *psContext);
|
||||
void highlightLost(W_CONTEXT *psContext);
|
||||
void run(W_CONTEXT *psContext);
|
||||
void highlightLost();
|
||||
void display(int xOffset, int yOffset);
|
||||
|
||||
bool disableChildren; ///< Disable all child widgets if true
|
||||
UWORD Ax0, Ay0, Ax1, Ay1; ///< Working coords for animations.
|
||||
UDWORD animCount; ///< Animation counter.
|
||||
UDWORD startTime; ///< Animation start time
|
||||
PIELIGHT aColours[WCOL_MAX]; ///< Colours for the form and its widgets
|
||||
WIDGET *psLastHiLite; ///< The last widget to be hilited. This is used to track when the mouse moves off something.
|
||||
WIDGET *psWidgets; ///< The widgets on the form
|
||||
};
|
||||
unsigned getState();
|
||||
void setState(unsigned state);
|
||||
void setFlash(bool enable);
|
||||
void setTip(QString string);
|
||||
|
||||
/* Information for a minor tab */
|
||||
struct W_MINORTAB
|
||||
{
|
||||
/* Graphics data for the tab will go here */
|
||||
WIDGET *psWidgets; // Widgets on the tab
|
||||
char *pTip; // Tool tip
|
||||
};
|
||||
void setString(char const *stringUtf8) { WIDGET::setString(stringUtf8); } // Unhide the WIDGET::setString(char const *) function...
|
||||
void setTip(char const *stringUtf8) { WIDGET::setTip(stringUtf8); } // Unhide the WIDGET::setTip(char const *) function...
|
||||
|
||||
/* Information for a major tab */
|
||||
struct W_MAJORTAB
|
||||
{
|
||||
/* Graphics data for the tab will go here */
|
||||
UWORD lastMinor; // Store which was the last selected minor tab
|
||||
UWORD numMinor;
|
||||
W_MINORTAB asMinor[WFORM_MAXMINOR]; // Minor tab information
|
||||
char *pTip;
|
||||
};
|
||||
|
||||
/* The tabbed form data structure */
|
||||
struct W_TABFORM : public W_FORM
|
||||
{
|
||||
W_TABFORM(W_FORMINIT const *init);
|
||||
|
||||
UWORD majorPos, minorPos; // Position of the tabs on the form
|
||||
UWORD majorSize, minorSize; // the size of tabs horizontally and vertically
|
||||
UWORD tabMajorThickness; // The thickness of the tabs
|
||||
UWORD tabMinorThickness; // The thickness of the tabs
|
||||
UWORD tabMajorGap; // The gap between tabs
|
||||
UWORD tabMinorGap; // The gap between tabs
|
||||
SWORD tabVertOffset; // Tab form overlap offset.
|
||||
SWORD tabHorzOffset; // Tab form overlap offset.
|
||||
SWORD majorOffset; // Tab start offset.
|
||||
SWORD minorOffset; // Tab start offset.
|
||||
UWORD majorT, minorT; // which tab is selected
|
||||
UWORD state; // Current state of the widget
|
||||
UWORD tabHiLite; // which tab is hilited.
|
||||
/* NOTE: If tabHiLite is (UWORD)(-1) then there is no hilite. A bit of a hack I know */
|
||||
/* but I don't really have the energy to change it. (Don't design stuff after */
|
||||
/* beers at lunch-time :-) */
|
||||
|
||||
UWORD numMajor; // The number of major tabs
|
||||
SWORD TabMultiplier; //used to tell system we got lots of tabs to display
|
||||
unsigned maxTabsShown; ///< Maximum number of tabs shown at once.
|
||||
UWORD numStats; //# of 'stats' (items) in list
|
||||
UWORD numButtons; //# of buttons per form
|
||||
W_MAJORTAB asMajor[WFORM_MAXMAJOR]; // The major tab information
|
||||
TAB_DISPLAY pTabDisplay; // Optional callback for display tabs.
|
||||
};
|
||||
|
||||
|
||||
/* Button states for a clickable form */
|
||||
#define WCLICK_NORMAL 0x0000
|
||||
#define WCLICK_DOWN 0x0001 // Button is down
|
||||
#define WCLICK_GREY 0x0002 // Button is disabled
|
||||
#define WCLICK_HILITE 0x0004 // Button is hilited
|
||||
#define WCLICK_LOCKED 0x0008 // Button is locked down
|
||||
#define WCLICK_CLICKLOCK 0x0010 // Button is locked but clickable
|
||||
#define WCLICK_FLASH 0x0020 // Button flashing is enabled
|
||||
#define WCLICK_FLASHON 0x0040 // Button is flashing
|
||||
|
||||
/* The clickable form data structure */
|
||||
struct W_CLICKFORM : public W_FORM
|
||||
{
|
||||
W_CLICKFORM(W_FORMINIT const *init);
|
||||
bool isDown() const;
|
||||
bool isHighlighted() const;
|
||||
|
||||
UDWORD state; // Button state of the form
|
||||
const char *pTip; // Tip for the form
|
||||
QString pTip; // Tip for the form
|
||||
SWORD HilightAudioID; // Audio ID for form clicked sound
|
||||
SWORD ClickedAudioID; // Audio ID for form hilighted sound
|
||||
WIDGET_AUDIOCALLBACK AudioCallback; // Pointer to audio callback function
|
||||
};
|
||||
|
||||
extern void formClearFlash(W_FORM *psWidget);
|
||||
|
||||
/* Create a form widget data structure */
|
||||
extern W_FORM *formCreate(const W_FORMINIT *psInit);
|
||||
|
||||
/* Free the memory used by a form */
|
||||
extern void formFree(W_FORM *psWidget);
|
||||
|
||||
/* Add a widget to a form */
|
||||
extern bool formAddWidget(W_FORM *psForm, WIDGET *psWidget, W_INIT *psInit);
|
||||
|
||||
/* Return the widgets currently displayed by a form */
|
||||
extern WIDGET *formGetWidgets(W_FORM *psWidget);
|
||||
|
||||
/* Return the origin on the form from which button locations are calculated */
|
||||
extern void formGetOrigin(W_FORM *psWidget, SDWORD *pXOrigin, SDWORD *pYOrigin);
|
||||
|
||||
/* Variables for the formGetAllWidgets functions */
|
||||
struct W_FORMGETALL
|
||||
{
|
||||
WIDGET *psGAWList;
|
||||
W_TABFORM *psGAWForm;
|
||||
W_MAJORTAB *psGAWMajor;
|
||||
UDWORD GAWMajor, GAWMinor;
|
||||
};
|
||||
|
||||
/* Initialise the formGetAllWidgets function */
|
||||
extern void formInitGetAllWidgets(W_FORM *psWidget, W_FORMGETALL *psCtrl);
|
||||
|
||||
/* Repeated calls to this function will return widget lists
|
||||
* until all widgets in a form have been returned.
|
||||
* When a NULL list is returned, all widgets have been seen.
|
||||
*/
|
||||
extern WIDGET *formGetAllWidgets(W_FORMGETALL *psCtrl);
|
||||
|
||||
/* Get the button state of a click form */
|
||||
extern UDWORD formGetClickState(W_CLICKFORM *psForm);
|
||||
|
||||
extern void formSetFlash(W_FORM *psWidget);
|
||||
|
||||
/* Set the button state of a click form */
|
||||
extern void formSetClickState(W_CLICKFORM *psForm, UDWORD state);
|
||||
|
||||
/* Display function prototypes */
|
||||
extern void formDisplay(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
extern void formDisplayClickable(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
extern void formDisplayTabbed(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
|
||||
#endif // __INCLUDED_LIB_WIDGET_FORM_H__
|
||||
|
|
|
@ -38,105 +38,100 @@ W_LABINIT::W_LABINIT()
|
|||
|
||||
W_LABEL::W_LABEL(W_LABINIT const *init)
|
||||
: WIDGET(init, WIDG_LABEL)
|
||||
, aText(QString::fromUtf8(init->pText))
|
||||
, FontID(init->FontID)
|
||||
, pTip(init->pTip)
|
||||
, pTip(QString::fromUtf8(init->pTip))
|
||||
, fontColour(WZCOL_FORM_TEXT)
|
||||
{
|
||||
if (display == NULL)
|
||||
{
|
||||
display = labelDisplay;
|
||||
}
|
||||
|
||||
aText[0] = '\0';
|
||||
if (init->pText)
|
||||
{
|
||||
sstrcpy(aText, init->pText);
|
||||
}
|
||||
ASSERT((init->style & ~(WLAB_PLAIN | WLAB_ALIGNLEFT | WLAB_ALIGNRIGHT | WLAB_ALIGNCENTRE | WLAB_ALIGNTOP | WLAB_ALIGNBOTTOM | WIDG_HIDDEN)) == 0, "Unknown button style");
|
||||
}
|
||||
|
||||
W_LABEL::W_LABEL(WIDGET *parent)
|
||||
: WIDGET(parent, WIDG_LABEL)
|
||||
, FontID(font_regular)
|
||||
, fontColour(WZCOL_FORM_TEXT)
|
||||
{}
|
||||
|
||||
/* Create a button widget data structure */
|
||||
W_LABEL *labelCreate(const W_LABINIT *psInit)
|
||||
void W_LABEL::display(int xOffset, int yOffset)
|
||||
{
|
||||
/* Do some validation on the initialisation struct */
|
||||
if (psInit->style & ~(WLAB_PLAIN | WLAB_ALIGNLEFT |
|
||||
WLAB_ALIGNRIGHT | WLAB_ALIGNCENTRE | WIDG_HIDDEN))
|
||||
if (displayFunction != NULL)
|
||||
{
|
||||
ASSERT(false, "Unknown button style");
|
||||
return NULL;
|
||||
displayFunction(this, xOffset, yOffset);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Allocate the required memory */
|
||||
W_LABEL *psWidget = new W_LABEL(psInit);
|
||||
if (psWidget == NULL)
|
||||
{
|
||||
debug(LOG_FATAL, "labelCreate: Out of memory");
|
||||
abort();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return psWidget;
|
||||
}
|
||||
|
||||
|
||||
/* Free the memory used by a button */
|
||||
void labelFree(W_LABEL *psWidget)
|
||||
{
|
||||
ASSERT(psWidget != NULL,
|
||||
"labelFree: Invalid label pointer");
|
||||
|
||||
delete psWidget;
|
||||
}
|
||||
|
||||
/* label display function */
|
||||
void labelDisplay(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours)
|
||||
{
|
||||
unsigned int fx, fy, fw;
|
||||
W_LABEL *psLabel;
|
||||
enum iV_fonts FontID;
|
||||
|
||||
psLabel = (W_LABEL *)psWidget;
|
||||
FontID = psLabel->FontID;
|
||||
|
||||
iV_SetFont(FontID);
|
||||
iV_SetTextColour(pColours[WCOL_TEXT]);
|
||||
iV_SetTextColour(fontColour);
|
||||
|
||||
if (psLabel->style & WLAB_ALIGNCENTRE)
|
||||
QByteArray text = aText.toUtf8();
|
||||
int fx;
|
||||
if (style & WLAB_ALIGNCENTRE)
|
||||
{
|
||||
fw = iV_GetTextWidth(psLabel->aText);
|
||||
fx = xOffset + psLabel->x + (psLabel->width - fw) / 2;
|
||||
int fw = iV_GetTextWidth(text.constData());
|
||||
fx = xOffset + x() + (width() - fw) / 2;
|
||||
}
|
||||
else if (psLabel->style & WLAB_ALIGNRIGHT)
|
||||
else if (style & WLAB_ALIGNRIGHT)
|
||||
{
|
||||
fw = iV_GetTextWidth(psLabel->aText);
|
||||
fx = xOffset + psLabel->x + psLabel->width - fw;
|
||||
int fw = iV_GetTextWidth(text.constData());
|
||||
fx = xOffset + x() + width() - fw;
|
||||
}
|
||||
else
|
||||
{
|
||||
fx = xOffset + psLabel->x;
|
||||
fx = xOffset + x();
|
||||
}
|
||||
fy = yOffset + psLabel->y + (psLabel->height - iV_GetTextLineSize()) / 2 - iV_GetTextAboveBase();
|
||||
iV_DrawText(psLabel->aText, fx, fy);
|
||||
int fy;
|
||||
if ((style & WLAB_ALIGNTOPLEFT) != 0) // Align top
|
||||
{
|
||||
fy = yOffset + y() - iV_GetTextAboveBase();
|
||||
}
|
||||
else if ((style & WLAB_ALIGNBOTTOMLEFT) != 0) // Align bottom
|
||||
{
|
||||
fy = yOffset + y() - iV_GetTextAboveBase() + (height() - iV_GetTextLineSize());
|
||||
}
|
||||
else
|
||||
{
|
||||
fy = yOffset + y() - iV_GetTextAboveBase() + (height() - iV_GetTextLineSize())/2;
|
||||
}
|
||||
iV_DrawText(text.constData(), fx, fy);
|
||||
}
|
||||
|
||||
/* Respond to a mouse moving over a label */
|
||||
void W_LABEL::highlight(W_CONTEXT *psContext)
|
||||
{
|
||||
/* If there is a tip string start the tool tip */
|
||||
if (pTip)
|
||||
if (!pTip.isEmpty())
|
||||
{
|
||||
tipStart(this, pTip, psContext->psScreen->TipFontID,
|
||||
psContext->psForm->aColours,
|
||||
x + psContext->xOffset, y + psContext->yOffset,
|
||||
width, height);
|
||||
tipStart(this, pTip, screenPointer->TipFontID, x() + psContext->xOffset, y() + psContext->yOffset, width(), height());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Respond to the mouse moving off a label */
|
||||
void W_LABEL::highlightLost(W_CONTEXT *)
|
||||
void W_LABEL::highlightLost()
|
||||
{
|
||||
if (pTip)
|
||||
if (!pTip.isEmpty())
|
||||
{
|
||||
tipStop(this);
|
||||
}
|
||||
}
|
||||
|
||||
QString W_LABEL::getString() const
|
||||
{
|
||||
return aText;
|
||||
}
|
||||
|
||||
void W_LABEL::setString(QString string)
|
||||
{
|
||||
aText = string;
|
||||
}
|
||||
|
||||
void W_LABEL::setTip(QString string)
|
||||
{
|
||||
pTip = string;
|
||||
}
|
||||
|
||||
void W_LABEL::setTextAlignment(WzTextAlignment align)
|
||||
{
|
||||
style &= ~(WLAB_ALIGNLEFT | WLAB_ALIGNCENTRE | WLAB_ALIGNRIGHT);
|
||||
style |= align;
|
||||
}
|
||||
|
|
|
@ -29,25 +29,36 @@
|
|||
#include "lib/ivis_opengl/textdraw.h"
|
||||
|
||||
|
||||
struct W_LABEL : public WIDGET
|
||||
class W_LABEL : public WIDGET
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
W_LABEL(W_LABINIT const *init);
|
||||
W_LABEL(WIDGET *parent);
|
||||
|
||||
void highlight(W_CONTEXT *psContext);
|
||||
void highlightLost(W_CONTEXT *);
|
||||
void highlightLost();
|
||||
void display(int xOffset, int yOffset);
|
||||
|
||||
char aText[WIDG_MAXSTR]; // Text on the label
|
||||
enum iV_fonts FontID;
|
||||
const char *pTip; // The tool tip for the button
|
||||
QString getString() const;
|
||||
void setString(QString string);
|
||||
void setTip(QString string);
|
||||
|
||||
void setFont(iV_fonts font) { FontID = font; }
|
||||
void setFontColour(PIELIGHT colour) { fontColour = colour; }
|
||||
void setFont(iV_fonts font, PIELIGHT colour) { setFont(font); setFontColour(colour); }
|
||||
void setTextAlignment(WzTextAlignment align);
|
||||
|
||||
void setString(char const *stringUtf8) { WIDGET::setString(stringUtf8); } // Unhide the WIDGET::setString(char const *) function...
|
||||
void setTip(char const *stringUtf8) { WIDGET::setTip(stringUtf8); } // Unhide the WIDGET::setTip(char const *) function...
|
||||
|
||||
QString aText; // Text on the label
|
||||
iV_fonts FontID;
|
||||
QString pTip; // The tool tip for the button
|
||||
|
||||
private:
|
||||
PIELIGHT fontColour;
|
||||
};
|
||||
|
||||
/* Create a button widget data structure */
|
||||
extern W_LABEL *labelCreate(const W_LABINIT *psInit);
|
||||
|
||||
/* Free the memory used by a button */
|
||||
extern void labelFree(W_LABEL *psWidget);
|
||||
|
||||
/* label display function */
|
||||
extern void labelDisplay(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
|
||||
#endif // __INCLUDED_LIB_WIDGET_LABEL_H__
|
||||
|
|
|
@ -0,0 +1,295 @@
|
|||
/*
|
||||
This file is part of Warzone 2100.
|
||||
Copyright (C) 1999-2004 Eidos Interactive
|
||||
Copyright (C) 2005-2013 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
|
||||
* Implementation of a list widget. Useful for displaying lists of buttons and stuff.
|
||||
*/
|
||||
|
||||
#include "listwidget.h"
|
||||
#include "button.h"
|
||||
#include <QtCore/QSignalMapper>
|
||||
|
||||
|
||||
TabSelectionStyle::TabSelectionStyle(Image tab, Image tabDown, Image tabHighlight, Image prev, Image prevDown, Image prevHighlight, Image next, Image nextDown, Image nextHighlight, int gap)
|
||||
: tabSize(tab.width(), tab.height())
|
||||
, scrollTabSize(0, 0)
|
||||
, tabImage(tab), tabImageDown(tabDown), tabImageHighlight(tabHighlight)
|
||||
, prevScrollTabImage(prev), prevScrollTabImageDown(prevDown), prevScrollTabImageHighlight(prevHighlight)
|
||||
, nextScrollTabImage(next), nextScrollTabImageDown(nextDown), nextScrollTabImageHighlight(nextHighlight)
|
||||
, tabGap(gap)
|
||||
{
|
||||
if (!prev.isNull())
|
||||
{
|
||||
scrollTabSize = QSize(prev.width(), prev.height());
|
||||
}
|
||||
}
|
||||
|
||||
TabSelectionWidget::TabSelectionWidget(WIDGET *parent)
|
||||
: WIDGET(parent)
|
||||
, currentTab(0)
|
||||
, tabsAtOnce(1)
|
||||
, prevTabPageButton(new W_BUTTON(this))
|
||||
, nextTabPageButton(new W_BUTTON(this))
|
||||
, setTabMapper(new QSignalMapper(this))
|
||||
{
|
||||
connect(setTabMapper, SIGNAL(mapped(int)), this, SLOT(setTab(int)));
|
||||
connect(prevTabPageButton, SIGNAL(clicked()), this, SLOT(prevTabPage()));
|
||||
connect(nextTabPageButton, SIGNAL(clicked()), this, SLOT(nextTabPage()));
|
||||
|
||||
prevTabPageButton->setTip(_("Tab Scroll left"));
|
||||
nextTabPageButton->setTip(_("Tab Scroll right"));
|
||||
|
||||
setHeight(5);
|
||||
setNumberOfTabs(1);
|
||||
}
|
||||
|
||||
void TabSelectionWidget::setHeight(int height)
|
||||
{
|
||||
setGeometry(x(), y(), width(), height);
|
||||
}
|
||||
|
||||
void TabSelectionWidget::addStyle(TabSelectionStyle const &style)
|
||||
{
|
||||
styles.push_back(style);
|
||||
|
||||
doLayoutAll();
|
||||
}
|
||||
|
||||
void TabSelectionWidget::setTab(int tab)
|
||||
{
|
||||
unsigned previousTab = currentTab;
|
||||
currentTab = clip(tab, 0, tabButtons.size() - 1);
|
||||
if (previousTab == currentTab)
|
||||
{
|
||||
return; // Nothing to do.
|
||||
}
|
||||
doLayoutAll();
|
||||
emit tabChanged(currentTab);
|
||||
}
|
||||
|
||||
void TabSelectionWidget::setNumberOfTabs(int tabs)
|
||||
{
|
||||
ASSERT_OR_RETURN(, tabs >= 0, "?");
|
||||
|
||||
unsigned previousSize = tabButtons.size();
|
||||
for (unsigned n = tabs; n < previousSize; ++n)
|
||||
{
|
||||
delete tabButtons[n];
|
||||
}
|
||||
tabButtons.resize(tabs);
|
||||
for (unsigned n = previousSize; n < tabButtons.size(); ++n)
|
||||
{
|
||||
tabButtons[n] = new W_BUTTON(this);
|
||||
connect(tabButtons[n], SIGNAL(clicked()), setTabMapper, SLOT(map()));
|
||||
setTabMapper->setMapping(tabButtons[n], n);
|
||||
}
|
||||
|
||||
doLayoutAll();
|
||||
}
|
||||
|
||||
void TabSelectionWidget::prevTabPage()
|
||||
{
|
||||
setTab(currentTab - tabsAtOnce);
|
||||
}
|
||||
|
||||
void TabSelectionWidget::nextTabPage()
|
||||
{
|
||||
setTab(currentTab + tabsAtOnce);
|
||||
}
|
||||
|
||||
void TabSelectionWidget::doLayoutAll()
|
||||
{
|
||||
TabSelectionStyle style;
|
||||
int scrollSpace = 0;
|
||||
tabsAtOnce = tabs();
|
||||
style.tabSize = QSize(width()/tabs(), height());
|
||||
style.scrollTabSize = QSize(0, 0);
|
||||
style.tabGap = 0;
|
||||
for (unsigned n = 0; n < styles.size(); ++n)
|
||||
{
|
||||
bool haveScroll_ = !styles[n].scrollTabSize.isEmpty();
|
||||
int scrollSpace_ = haveScroll_? styles[n].scrollTabSize.width() + styles[n].tabGap : 0;
|
||||
int tabsAtOnce_ = (width() + styles[n].tabGap - scrollSpace_*2)/(styles[n].tabSize.width() + styles[n].tabGap);
|
||||
if (haveScroll_ || tabs() <= tabsAtOnce_)
|
||||
{
|
||||
scrollSpace = scrollSpace_;
|
||||
tabsAtOnce = tabsAtOnce_;
|
||||
style = styles[n];
|
||||
break;
|
||||
}
|
||||
}
|
||||
prevTabPageButton->setGeometry(0, 0, style.scrollTabSize.width(), style.scrollTabSize.height());
|
||||
prevTabPageButton->setImages(style.prevScrollTabImage, style.prevScrollTabImageDown, style.prevScrollTabImageHighlight);
|
||||
prevTabPageButton->show(currentTab >= tabsAtOnce);
|
||||
nextTabPageButton->setGeometry(width() - style.scrollTabSize.width(), 0, style.scrollTabSize.width(), style.scrollTabSize.height());
|
||||
nextTabPageButton->setImages(style.nextScrollTabImage, style.nextScrollTabImageDown, style.nextScrollTabImageHighlight);
|
||||
nextTabPageButton->show(currentTab/tabsAtOnce < (tabs() - 1)/tabsAtOnce);
|
||||
for (unsigned n = 0; n < tabButtons.size(); ++n)
|
||||
{
|
||||
tabButtons[n]->setGeometry(scrollSpace + n%tabsAtOnce*(style.tabSize.width() + style.tabGap), 0, style.tabSize.width(), style.tabSize.height());
|
||||
tabButtons[n]->setImages(style.tabImage, style.tabImageDown, style.tabImageHighlight);
|
||||
tabButtons[n]->show(currentTab/tabsAtOnce == n/tabsAtOnce);
|
||||
tabButtons[n]->setState(n == currentTab? WBUT_LOCK : 0);
|
||||
}
|
||||
if (tabButtons.size() == 1)
|
||||
{
|
||||
tabButtons[0]->hide(); // Don't show single tabs.
|
||||
}
|
||||
}
|
||||
|
||||
ListWidget::ListWidget(WIDGET *parent)
|
||||
: WIDGET(parent)
|
||||
, childSize(10, 10)
|
||||
, spacing(4, 4)
|
||||
, currentPage_(0)
|
||||
, order(RightThenDown)
|
||||
{}
|
||||
|
||||
void ListWidget::widgetLost(WIDGET *widget)
|
||||
{
|
||||
std::vector<WIDGET *>::iterator i = std::find(myChildren.begin(), myChildren.end(), widget);
|
||||
if (i != myChildren.end())
|
||||
{
|
||||
myChildren.erase(i);
|
||||
doLayoutAll();
|
||||
}
|
||||
}
|
||||
|
||||
void ListWidget::setChildSize(int width, int height)
|
||||
{
|
||||
childSize = QSize(width, height);
|
||||
doLayoutAll();
|
||||
}
|
||||
|
||||
void ListWidget::setChildSpacing(int width, int height)
|
||||
{
|
||||
spacing = QSize(width, height);
|
||||
doLayoutAll();
|
||||
}
|
||||
|
||||
void ListWidget::setOrder(Order order_)
|
||||
{
|
||||
order = order_;
|
||||
doLayoutAll();
|
||||
}
|
||||
|
||||
void ListWidget::addWidgetToLayout(WIDGET *widget)
|
||||
{
|
||||
int oldNumPages = pages();
|
||||
|
||||
myChildren.push_back(widget);
|
||||
doLayout(myChildren.size() - 1);
|
||||
|
||||
int numPages = pages();
|
||||
if (oldNumPages != numPages)
|
||||
{
|
||||
emit numberOfPagesChanged(numPages);
|
||||
}
|
||||
}
|
||||
|
||||
void ListWidget::setCurrentPage(int page)
|
||||
{
|
||||
unsigned previousPage = currentPage_;
|
||||
int pp = widgetsPerPage();
|
||||
currentPage_ = clip(page, 0, pages() - 1);
|
||||
if (previousPage == currentPage_)
|
||||
{
|
||||
return; // Nothing to do.
|
||||
}
|
||||
for (unsigned n = pp*previousPage; n < pp*(previousPage + 1) && n < myChildren.size(); ++n)
|
||||
{
|
||||
myChildren[n]->hide();
|
||||
}
|
||||
for (unsigned n = pp*currentPage_; n < pp*(currentPage_ + 1) && n < myChildren.size(); ++n)
|
||||
{
|
||||
myChildren[n]->show();
|
||||
}
|
||||
emit currentPageChanged(currentPage_);
|
||||
}
|
||||
|
||||
void ListWidget::doLayoutAll()
|
||||
{
|
||||
for (unsigned n = 0; n < myChildren.size(); ++n)
|
||||
{
|
||||
doLayout(n);
|
||||
}
|
||||
}
|
||||
|
||||
void ListWidget::doLayout(int num)
|
||||
{
|
||||
unsigned page = num/widgetsPerPage();
|
||||
int withinPage = num%widgetsPerPage();
|
||||
int column = 0, row = 0;
|
||||
switch (order)
|
||||
{
|
||||
case RightThenDown:
|
||||
column = withinPage%widgetsPerRow();
|
||||
row = withinPage/widgetsPerRow();
|
||||
break;
|
||||
case DownThenRight:
|
||||
column = withinPage/widgetsPerColumn();
|
||||
row = withinPage%widgetsPerColumn();
|
||||
break;
|
||||
}
|
||||
myChildren[num]->setGeometry(column*widgetSkipX(), row*widgetSkipY(), childSize.width(), childSize.height());
|
||||
myChildren[num]->show(page == currentPage_);
|
||||
}
|
||||
|
||||
ListTabWidget::ListTabWidget(WIDGET *parent)
|
||||
: WIDGET(parent)
|
||||
, tabs(new TabSelectionWidget(this))
|
||||
, widgets(new ListWidget(this))
|
||||
, tabPos(Top)
|
||||
{
|
||||
connect(tabs, SIGNAL(tabChanged(int)), widgets, SLOT(setCurrentPage(int)));
|
||||
connect(widgets, SIGNAL(currentPageChanged(int)), tabs, SLOT(setTab(int)));
|
||||
connect(widgets, SIGNAL(numberOfPagesChanged(int)), tabs, SLOT(setNumberOfTabs(int)));
|
||||
tabs->setNumberOfTabs(widgets->pages());
|
||||
}
|
||||
|
||||
void ListTabWidget::geometryChanged()
|
||||
{
|
||||
switch (tabPos)
|
||||
{
|
||||
case Top:
|
||||
tabs->setGeometry(0, 0, width(), tabs->height());
|
||||
widgets->setGeometry(0, tabs->height(), width(), height() - tabs->height());
|
||||
break;
|
||||
case Bottom:
|
||||
tabs->setGeometry(0, height() - tabs->height(), width(), tabs->height());
|
||||
widgets->setGeometry(0, 0, width(), height() - tabs->height());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ListTabWidget::addWidgetToLayout(WIDGET *widget)
|
||||
{
|
||||
if (widget->parent() == this)
|
||||
{
|
||||
detach(widget);
|
||||
widgets->attach(widget);
|
||||
}
|
||||
widgets->addWidgetToLayout(widget);
|
||||
}
|
||||
|
||||
void ListTabWidget::setTabPosition(TabPosition pos)
|
||||
{
|
||||
tabPos = pos;
|
||||
geometryChanged();
|
||||
}
|
|
@ -0,0 +1,152 @@
|
|||
/*
|
||||
This file is part of Warzone 2100.
|
||||
Copyright (C) 1999-2004 Eidos Interactive
|
||||
Copyright (C) 2005-2013 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 listwidget.h
|
||||
* \brief A list widget. Useful for displaying lists of buttons and stuff.
|
||||
*/
|
||||
|
||||
#ifndef THISISALISTWIDGET_H
|
||||
#define THISISALISTWIDGET_H
|
||||
|
||||
#include "widget.h"
|
||||
|
||||
|
||||
struct TabSelectionStyle
|
||||
{
|
||||
TabSelectionStyle() {}
|
||||
TabSelectionStyle(Image tab, Image tabDown, Image tabHighlight, Image prev, Image prevDown, Image prevHighlight, Image next, Image nextDown, Image nextHighlight, int gap);
|
||||
|
||||
QSize tabSize;
|
||||
QSize scrollTabSize;
|
||||
Image tabImage, tabImageDown, tabImageHighlight;
|
||||
Image prevScrollTabImage, prevScrollTabImageDown, prevScrollTabImageHighlight;
|
||||
Image nextScrollTabImage, nextScrollTabImageDown, nextScrollTabImageHighlight;
|
||||
int tabGap;
|
||||
};
|
||||
|
||||
class TabSelectionWidget : public WIDGET
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TabSelectionWidget(WIDGET *parent);
|
||||
|
||||
void setHeight(int height);
|
||||
void addStyle(TabSelectionStyle const &style);
|
||||
|
||||
int tabs() const { return tabButtons.size(); }
|
||||
|
||||
signals:
|
||||
void tabChanged(int);
|
||||
|
||||
public slots:
|
||||
void setTab(int tab);
|
||||
void setNumberOfTabs(int tabs);
|
||||
|
||||
private slots:
|
||||
void prevTabPage();
|
||||
void nextTabPage();
|
||||
|
||||
private:
|
||||
void doLayoutAll();
|
||||
|
||||
std::vector<TabSelectionStyle> styles;
|
||||
unsigned currentTab;
|
||||
unsigned tabsAtOnce;
|
||||
std::vector<W_BUTTON *> tabButtons;
|
||||
W_BUTTON *prevTabPageButton;
|
||||
W_BUTTON *nextTabPageButton;
|
||||
class QSignalMapper *setTabMapper;
|
||||
};
|
||||
|
||||
class ListWidget : public WIDGET
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Order {RightThenDown, DownThenRight};
|
||||
|
||||
ListWidget(WIDGET *parent);
|
||||
|
||||
virtual void widgetLost(WIDGET *widget);
|
||||
|
||||
void setChildSize(int width, int height); ///< Sets the size of all child widgets (applied by calling addWidgetToLayout).
|
||||
void setChildSpacing(int width, int height); ///< Sets the distance between child widgets (applied by calling addWidgetToLayout).
|
||||
void setOrder(Order order); ///< Sets whether subsequent child widgets are placed in horizontal or vertical lines (applied by calling addWidgetToLayout).
|
||||
void addWidgetToLayout(WIDGET *widget); ///< Manages the geometry of widget, and shows/hides it when changing tabs.
|
||||
|
||||
int currentPage() const { return currentPage_; }
|
||||
int pages() const { return std::max(((int)myChildren.size() - 1)/widgetsPerPage(), 0) + 1; }
|
||||
|
||||
signals:
|
||||
void currentPageChanged(int);
|
||||
void numberOfPagesChanged(int);
|
||||
|
||||
public slots:
|
||||
void setCurrentPage(int page);
|
||||
|
||||
private:
|
||||
void doLayoutAll();
|
||||
void doLayout(int num);
|
||||
|
||||
int widgetsPerPage() const { return widgetsPerRow()*widgetsPerColumn(); }
|
||||
int widgetsPerRow() const { return std::max((width() + spacing.width())/widgetSkipX(), 1); }
|
||||
int widgetsPerColumn() const { return std::max((height() + spacing.height())/widgetSkipY(), 1); }
|
||||
int widgetSkipX() const { return childSize.width() + spacing.width(); }
|
||||
int widgetSkipY() const { return childSize.height() + spacing.height(); }
|
||||
|
||||
QSize childSize;
|
||||
QSize spacing;
|
||||
unsigned currentPage_;
|
||||
std::vector<WIDGET *> myChildren;
|
||||
Order order;
|
||||
};
|
||||
|
||||
class ListTabWidget : public WIDGET
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum TabPosition {Top, Bottom};
|
||||
|
||||
ListTabWidget(WIDGET *parent);
|
||||
|
||||
virtual void geometryChanged();
|
||||
|
||||
void setChildSize(int width, int height) { widgets->setChildSize(width, height); } ///< Sets the size of all child widgets (applied by calling addWidgetToLayout).
|
||||
void setChildSpacing(int width, int height) { widgets->setChildSpacing(width, height); } ///< Sets the distance between child widgets (applied by calling addWidgetToLayout).
|
||||
void setOrder(ListWidget::Order order) { widgets->setOrder(order); } ///< Sets whether subsequent child widgets are placed in horizontal or vertical lines (applied by calling addWidgetToLayout).
|
||||
void addWidgetToLayout(WIDGET *widget); ///< Manages the geometry of widget, and shows/hides it when changing tabs.
|
||||
bool setCurrentPage(int page) { widgets->setCurrentPage(page); return widgets->currentPage() == page; }
|
||||
int currentPage() const { return widgets->currentPage(); }
|
||||
int pages() const { return widgets->pages(); }
|
||||
|
||||
void setTabPosition(TabPosition pos);
|
||||
|
||||
TabSelectionWidget *tabWidget() { return tabs; }
|
||||
ListWidget *listWidget() { return widgets; }
|
||||
|
||||
private:
|
||||
TabSelectionWidget *tabs;
|
||||
ListWidget *widgets;
|
||||
TabPosition tabPos;
|
||||
};
|
||||
|
||||
#endif //THISISALISTWIDGET_H
|
|
@ -47,97 +47,21 @@ W_SLIDER::W_SLIDER(W_SLDINIT const *init)
|
|||
, orientation(init->orientation)
|
||||
, numStops(init->numStops)
|
||||
, barSize(init->barSize)
|
||||
, pTip(init->pTip)
|
||||
, pos(init->pos)
|
||||
, state(0)
|
||||
, pTip(QString::fromUtf8(init->pTip))
|
||||
{
|
||||
if (display == NULL)
|
||||
{
|
||||
display = sliderDisplay;
|
||||
}
|
||||
|
||||
sliderInitialise(this);
|
||||
|
||||
pos = init->pos; // Must be after sliderInitialise().
|
||||
ASSERT((init->style & ~(WBAR_PLAIN | WIDG_HIDDEN)) == 0, "Unknown style");
|
||||
ASSERT(init->orientation >= WSLD_LEFT || init->orientation <= WSLD_BOTTOM, "Unknown orientation");
|
||||
bool horizontal = init->orientation == WSLD_LEFT || init->orientation == WSLD_RIGHT;
|
||||
bool vertical = init->orientation == WSLD_TOP || init->orientation == WSLD_BOTTOM;
|
||||
ASSERT((!horizontal || init->numStops <= init->width - init->barSize) &&
|
||||
(!vertical || init->numStops <= init->height - init->barSize), "Too many stops for slider length");
|
||||
ASSERT(init->pos <= init->numStops, "Slider position greater than stops (%d/%d)", init->pos, init->numStops);
|
||||
ASSERT((!horizontal || init->barSize <= init->width) &&
|
||||
(!vertical || init->barSize <= init->height), "Slider bar is larger than slider width");
|
||||
}
|
||||
|
||||
|
||||
/* Create a slider widget data structure */
|
||||
W_SLIDER *sliderCreate(const W_SLDINIT *psInit)
|
||||
{
|
||||
if (psInit->style & ~(WBAR_PLAIN | WIDG_HIDDEN))
|
||||
{
|
||||
ASSERT(false, "sliderCreate: Unknown style");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (psInit->orientation < WSLD_LEFT
|
||||
|| psInit->orientation > WSLD_BOTTOM)
|
||||
{
|
||||
ASSERT(false, "sliderCreate: Unknown orientation");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (((psInit->orientation == WSLD_LEFT
|
||||
|| psInit->orientation == WSLD_RIGHT)
|
||||
&& psInit->numStops > (psInit->width - psInit->barSize))
|
||||
|| ((psInit->orientation == WSLD_TOP
|
||||
|| psInit->orientation == WSLD_BOTTOM)
|
||||
&& psInit->numStops > (psInit->height - psInit->barSize)))
|
||||
{
|
||||
ASSERT(false, "sliderCreate: Too many stops for slider length");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (psInit->pos > psInit->numStops)
|
||||
{
|
||||
ASSERT(false, "sliderCreate: slider position greater than stops (%d/%d)", psInit->pos, psInit->numStops);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (((psInit->orientation == WSLD_LEFT
|
||||
|| psInit->orientation == WSLD_RIGHT)
|
||||
&& psInit->barSize > psInit->width)
|
||||
|| ((psInit->orientation == WSLD_TOP
|
||||
|| psInit->orientation == WSLD_BOTTOM)
|
||||
&& psInit->barSize > psInit->height))
|
||||
{
|
||||
ASSERT(false, "sliderCreate: slider bar is larger than slider width");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Allocate the required memory */
|
||||
W_SLIDER *psWidget = new W_SLIDER(psInit);
|
||||
if (psWidget == NULL)
|
||||
{
|
||||
debug(LOG_FATAL, "sliderCreate: Out of memory");
|
||||
abort();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return psWidget;
|
||||
}
|
||||
|
||||
|
||||
/* Free the memory used by a slider */
|
||||
void sliderFree(W_SLIDER *psWidget)
|
||||
{
|
||||
ASSERT(psWidget != NULL,
|
||||
"sliderFree: Invalid widget pointer");
|
||||
|
||||
delete psWidget;
|
||||
}
|
||||
|
||||
|
||||
/* Initialise a slider widget before running it */
|
||||
void sliderInitialise(W_SLIDER *psWidget)
|
||||
{
|
||||
ASSERT(psWidget != NULL,
|
||||
"sliderInitialise: Invalid slider pointer");
|
||||
|
||||
psWidget->state = 0;
|
||||
psWidget->pos = 0;
|
||||
}
|
||||
|
||||
|
||||
/* Get the current position of a slider bar */
|
||||
UDWORD widgGetSliderPos(W_SCREEN *psScreen, UDWORD id)
|
||||
{
|
||||
|
@ -176,39 +100,38 @@ void widgSetSliderPos(W_SCREEN *psScreen, UDWORD id, UWORD pos)
|
|||
}
|
||||
|
||||
/* Return the current position of the slider bar on the widget */
|
||||
static void sliderGetBarBox(W_SLIDER *psSlider, SWORD *pX, SWORD *pY,
|
||||
UWORD *pWidth, UWORD *pHeight)
|
||||
static void sliderGetBarBox(W_SLIDER *psSlider, int *pX, int *pY, int *pWidth, int *pHeight)
|
||||
{
|
||||
switch (psSlider->orientation)
|
||||
{
|
||||
case WSLD_LEFT:
|
||||
*pX = (SWORD)((psSlider->width - psSlider->barSize)
|
||||
* psSlider->pos / psSlider->numStops);
|
||||
*pX = (psSlider->width() - psSlider->barSize)
|
||||
* psSlider->pos / psSlider->numStops;
|
||||
*pY = 0;
|
||||
*pWidth = psSlider->barSize;
|
||||
*pHeight = psSlider->height;
|
||||
*pHeight = psSlider->height();
|
||||
break;
|
||||
case WSLD_RIGHT:
|
||||
*pX = (SWORD)(psSlider->width - psSlider->barSize
|
||||
- (psSlider->width - psSlider->barSize)
|
||||
* psSlider->pos / psSlider->numStops);
|
||||
*pX = psSlider->width() - psSlider->barSize
|
||||
- (psSlider->width() - psSlider->barSize)
|
||||
* psSlider->pos / psSlider->numStops;
|
||||
*pY = 0;
|
||||
*pWidth = psSlider->barSize;
|
||||
*pHeight = psSlider->height;
|
||||
*pHeight = psSlider->height();
|
||||
break;
|
||||
case WSLD_TOP:
|
||||
*pX = 0;
|
||||
*pY = (SWORD)((psSlider->height - psSlider->barSize)
|
||||
* psSlider->pos / psSlider->numStops);
|
||||
*pWidth = psSlider->width;
|
||||
*pY = (psSlider->height() - psSlider->barSize)
|
||||
* psSlider->pos / psSlider->numStops;
|
||||
*pWidth = psSlider->width();
|
||||
*pHeight = psSlider->barSize;
|
||||
break;
|
||||
case WSLD_BOTTOM:
|
||||
*pX = 0;
|
||||
*pY = (SWORD)(psSlider->height - psSlider->barSize
|
||||
- (psSlider->height - psSlider->barSize)
|
||||
* psSlider->pos / psSlider->numStops);
|
||||
*pWidth = psSlider->width;
|
||||
*pY = psSlider->height() - psSlider->barSize
|
||||
- (psSlider->height() - psSlider->barSize)
|
||||
* psSlider->pos / psSlider->numStops;
|
||||
*pWidth = psSlider->width();
|
||||
*pHeight = psSlider->barSize;
|
||||
break;
|
||||
}
|
||||
|
@ -218,141 +141,109 @@ static void sliderGetBarBox(W_SLIDER *psSlider, SWORD *pX, SWORD *pY,
|
|||
/* Run a slider widget */
|
||||
void W_SLIDER::run(W_CONTEXT *psContext)
|
||||
{
|
||||
W_SLIDER *psWidget = this;
|
||||
SDWORD mx, my;
|
||||
UDWORD stopSize;
|
||||
|
||||
if ((psWidget->state & SLD_DRAG) && !mouseDown(MOUSE_LMB))
|
||||
if ((state & SLD_DRAG) && !mouseDown(MOUSE_LMB))
|
||||
{
|
||||
psWidget->state &= ~SLD_DRAG;
|
||||
widgSetReturn(psContext->psScreen, (WIDGET *)psWidget);
|
||||
state &= ~SLD_DRAG;
|
||||
screenPointer->setReturn(this);
|
||||
}
|
||||
else if (!(psWidget->state & SLD_DRAG) && mouseDown(MOUSE_LMB))
|
||||
else if (!(state & SLD_DRAG) && mouseDown(MOUSE_LMB))
|
||||
{
|
||||
clicked(psContext, WKEY_NONE);
|
||||
}
|
||||
if (psWidget->state & SLD_DRAG)
|
||||
if (state & SLD_DRAG)
|
||||
{
|
||||
/* Figure out where the drag box should be */
|
||||
mx = psContext->mx - psWidget->x;
|
||||
my = psContext->my - psWidget->y;
|
||||
switch (psWidget->orientation)
|
||||
int mx = psContext->mx - x();
|
||||
int my = psContext->my - y();
|
||||
int stopSize;
|
||||
switch (orientation)
|
||||
{
|
||||
case WSLD_LEFT:
|
||||
if (mx <= psWidget->barSize / 2)
|
||||
if (mx <= barSize / 2)
|
||||
{
|
||||
psWidget->pos = 0;
|
||||
pos = 0;
|
||||
}
|
||||
else if (mx >= psWidget->width - psWidget->barSize / 2)
|
||||
else if (mx >= width() - barSize / 2)
|
||||
{
|
||||
psWidget->pos = psWidget->numStops;
|
||||
pos = numStops;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Mouse is in the middle of the slider, calculate which stop */
|
||||
stopSize = (psWidget->width - psWidget->barSize) / psWidget->numStops;
|
||||
psWidget->pos = (UWORD)((mx + stopSize / 2 - psWidget->barSize / 2)
|
||||
* psWidget->numStops
|
||||
/ (psWidget->width - psWidget->barSize));
|
||||
stopSize = (width() - barSize) / numStops;
|
||||
pos = (mx + stopSize / 2 - barSize / 2)
|
||||
* numStops
|
||||
/ (width() - barSize);
|
||||
}
|
||||
break;
|
||||
case WSLD_RIGHT:
|
||||
if (mx <= psWidget->barSize / 2)
|
||||
if (mx <= barSize / 2)
|
||||
{
|
||||
psWidget->pos = psWidget->numStops;
|
||||
pos = numStops;
|
||||
}
|
||||
else if (mx >= psWidget->width - psWidget->barSize / 2)
|
||||
else if (mx >= width() - barSize / 2)
|
||||
{
|
||||
psWidget->pos = 0;
|
||||
pos = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Mouse is in the middle of the slider, calculate which stop */
|
||||
stopSize = (psWidget->width - psWidget->barSize) / psWidget->numStops;
|
||||
psWidget->pos = (UWORD)(psWidget->numStops
|
||||
- (mx + stopSize / 2 - psWidget->barSize / 2)
|
||||
* psWidget->numStops
|
||||
/ (psWidget->width - psWidget->barSize));
|
||||
stopSize = (width() - barSize) / numStops;
|
||||
pos = numStops
|
||||
- (mx + stopSize / 2 - barSize / 2)
|
||||
* numStops
|
||||
/ (width() - barSize);
|
||||
}
|
||||
break;
|
||||
case WSLD_TOP:
|
||||
if (my <= psWidget->barSize / 2)
|
||||
if (my <= barSize / 2)
|
||||
{
|
||||
psWidget->pos = 0;
|
||||
pos = 0;
|
||||
}
|
||||
else if (my >= psWidget->height - psWidget->barSize / 2)
|
||||
else if (my >= height() - barSize / 2)
|
||||
{
|
||||
psWidget->pos = psWidget->numStops;
|
||||
pos = numStops;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Mouse is in the middle of the slider, calculate which stop */
|
||||
stopSize = (psWidget->height - psWidget->barSize) / psWidget->numStops;
|
||||
psWidget->pos = (UWORD)((my + stopSize / 2 - psWidget->barSize / 2)
|
||||
* psWidget->numStops
|
||||
/ (psWidget->height - psWidget->barSize));
|
||||
stopSize = (height() - barSize) / numStops;
|
||||
pos = (my + stopSize / 2 - barSize / 2)
|
||||
* numStops
|
||||
/ (height() - barSize);
|
||||
}
|
||||
break;
|
||||
case WSLD_BOTTOM:
|
||||
if (my <= psWidget->barSize / 2)
|
||||
if (my <= barSize / 2)
|
||||
{
|
||||
psWidget->pos = psWidget->numStops;
|
||||
pos = numStops;
|
||||
}
|
||||
else if (my >= psWidget->height - psWidget->barSize / 2)
|
||||
else if (my >= height() - barSize / 2)
|
||||
{
|
||||
psWidget->pos = 0;
|
||||
pos = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Mouse is in the middle of the slider, calculate which stop */
|
||||
stopSize = (psWidget->height - psWidget->barSize) / psWidget->numStops;
|
||||
psWidget->pos = (UWORD)(psWidget->numStops
|
||||
- (my + stopSize / 2 - psWidget->barSize / 2)
|
||||
* psWidget->numStops
|
||||
/ (psWidget->height - psWidget->barSize));
|
||||
stopSize = (height() - barSize) / numStops;
|
||||
pos = numStops
|
||||
- (my + stopSize / 2 - barSize / 2)
|
||||
* numStops
|
||||
/ (height() - barSize);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Respond to a mouse click */
|
||||
void W_SLIDER::clicked(W_CONTEXT *psContext, WIDGET_KEY)
|
||||
{
|
||||
W_SLIDER *psWidget = this;
|
||||
#if 0
|
||||
SWORD x, y;
|
||||
UWORD width, height;
|
||||
SDWORD mx, my;
|
||||
|
||||
/* Get the slider position */
|
||||
sliderGetBarBox(psWidget, &x, &y, &width, &height);
|
||||
|
||||
/* Did the mouse click on the slider ? */
|
||||
mx = psContext->mx - psWidget->x;
|
||||
my = psContext->my - psWidget->y;
|
||||
#endif
|
||||
if (DragEnabled)
|
||||
if (DragEnabled && geometry().contains(psContext->mx, psContext->my))
|
||||
{
|
||||
if (psContext->mx >= psWidget->x &&
|
||||
psContext->mx <= psWidget->x + psWidget->width &&
|
||||
psContext->my >= psWidget->y &&
|
||||
psContext->my <= psWidget->y + psWidget->height)
|
||||
{
|
||||
psWidget->state |= SLD_DRAG;
|
||||
}
|
||||
state |= SLD_DRAG;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Respond to a mouse up */
|
||||
void W_SLIDER::released(W_CONTEXT *, WIDGET_KEY)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/* Respond to a mouse moving over a slider */
|
||||
void W_SLIDER::highlight(W_CONTEXT *)
|
||||
{
|
||||
state |= SLD_HILITE;
|
||||
|
@ -360,64 +251,70 @@ void W_SLIDER::highlight(W_CONTEXT *)
|
|||
|
||||
|
||||
/* Respond to the mouse moving off a slider */
|
||||
void W_SLIDER::highlightLost(W_CONTEXT *)
|
||||
void W_SLIDER::highlightLost()
|
||||
{
|
||||
state &= ~SLD_HILITE;
|
||||
}
|
||||
|
||||
/* The slider display function */
|
||||
void sliderDisplay(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours)
|
||||
void W_SLIDER::display(int xOffset, int yOffset)
|
||||
{
|
||||
W_SLIDER *psSlider;
|
||||
SWORD x0, y0, x1, y1;
|
||||
UWORD width = 0, height = 0;
|
||||
if (displayFunction != NULL)
|
||||
{
|
||||
displayFunction(this, xOffset, yOffset);
|
||||
return;
|
||||
}
|
||||
|
||||
psSlider = (W_SLIDER *)psWidget;
|
||||
int x0, y0, x1, y1, bbwidth = 0, bbheight = 0;
|
||||
|
||||
switch (psSlider->orientation)
|
||||
switch (orientation)
|
||||
{
|
||||
case WSLD_LEFT:
|
||||
case WSLD_RIGHT:
|
||||
/* Draw the line */
|
||||
x0 = (SWORD)(psSlider->x + xOffset + psSlider->barSize / (SWORD)2);
|
||||
y0 = (SWORD)(psSlider->y + yOffset + psSlider->height / (SWORD)2);
|
||||
x1 = (SWORD)(x0 + psSlider->width - psSlider->barSize);
|
||||
iV_Line(x0, y0, x1, y0, pColours[WCOL_DARK]);
|
||||
iV_Line(x0, y0 + 1, x1, y0 + 1, pColours[WCOL_LIGHT]);
|
||||
x0 = x() + xOffset + barSize / 2;
|
||||
y0 = y() + yOffset + height() / 2;
|
||||
x1 = x0 + width() - barSize;
|
||||
iV_Line(x0, y0, x1, y0, WZCOL_FORM_DARK);
|
||||
iV_Line(x0, y0 + 1, x1, y0 + 1, WZCOL_FORM_LIGHT);
|
||||
|
||||
/* Now Draw the bar */
|
||||
sliderGetBarBox(psSlider, &x0, &y0, &width, &height);
|
||||
x0 = (SWORD)(x0 + psSlider->x + xOffset);
|
||||
y0 = (SWORD)(y0 + psSlider->y + yOffset);
|
||||
x1 = (SWORD)(x0 + width);
|
||||
y1 = (SWORD)(y0 + height);
|
||||
iV_ShadowBox(x0, y0, x1, y1, 0, pColours[WCOL_LIGHT], pColours[WCOL_DARK], pColours[WCOL_BKGRND]);
|
||||
sliderGetBarBox(this, &x0, &y0, &bbwidth, &bbheight);
|
||||
x0 = x0 + x() + xOffset;
|
||||
y0 = y0 + y() + yOffset;
|
||||
x1 = x0 + bbwidth;
|
||||
y1 = y0 + bbheight;
|
||||
iV_ShadowBox(x0, y0, x1, y1, 0, WZCOL_FORM_LIGHT, WZCOL_FORM_DARK, WZCOL_FORM_BACKGROUND);
|
||||
break;
|
||||
case WSLD_TOP:
|
||||
case WSLD_BOTTOM:
|
||||
/* Draw the line */
|
||||
x0 = (SWORD)(psSlider->x + xOffset + psSlider->width / (SWORD)2);
|
||||
y0 = (SWORD)(psSlider->y + yOffset + psSlider->barSize / (SWORD)2);
|
||||
y1 = (SWORD)(y0 + psSlider->height - psSlider->barSize);
|
||||
iV_Line(x0, y0, x0, y1, pColours[WCOL_DARK]);
|
||||
iV_Line(x0 + 1, y0, x0 + 1, y1, pColours[WCOL_LIGHT]);
|
||||
x0 = x() + xOffset + width() / 2;
|
||||
y0 = y() + yOffset + barSize / 2;
|
||||
y1 = y0 + height() - barSize;
|
||||
iV_Line(x0, y0, x0, y1, WZCOL_FORM_DARK);
|
||||
iV_Line(x0 + 1, y0, x0 + 1, y1, WZCOL_FORM_LIGHT);
|
||||
|
||||
/* Now Draw the bar */
|
||||
sliderGetBarBox(psSlider, &x0, &y0, &width, &height);
|
||||
x0 = (SWORD)(x0 + psSlider->x + xOffset);
|
||||
y0 = (SWORD)(y0 + psSlider->y + yOffset);
|
||||
x1 = (SWORD)(x0 + width);
|
||||
y1 = (SWORD)(y0 + height);
|
||||
iV_ShadowBox(x0, y0, x1, y1, 0, pColours[WCOL_LIGHT], pColours[WCOL_DARK], pColours[WCOL_BKGRND]);
|
||||
sliderGetBarBox(this, &x0, &y0, &bbwidth, &bbheight);
|
||||
x0 = x0 + x() + xOffset;
|
||||
y0 = y0 + y() + yOffset;
|
||||
x1 = x0 + bbwidth;
|
||||
y1 = y0 + bbheight;
|
||||
iV_ShadowBox(x0, y0, x1, y1, 0, WZCOL_FORM_LIGHT, WZCOL_FORM_DARK, WZCOL_FORM_BACKGROUND);
|
||||
break;
|
||||
}
|
||||
|
||||
if (psSlider->state & SLD_HILITE)
|
||||
if ((state & SLD_HILITE) != 0)
|
||||
{
|
||||
x0 = (SWORD)(psWidget->x + xOffset - 2);
|
||||
y0 = (SWORD)(psWidget->y + yOffset - 2);
|
||||
x1 = (SWORD)(x0 + psWidget->width + 4);
|
||||
y1 = (SWORD)(y0 + psWidget->height + 4);
|
||||
iV_Box(x0, y0, x1, y1, pColours[WCOL_HILITE]);
|
||||
x0 = x() + xOffset - 2;
|
||||
y0 = y() + yOffset - 2;
|
||||
x1 = x0 + width() + 4;
|
||||
y1 = y0 + height() + 4;
|
||||
iV_Box(x0, y0, x1, y1, WZCOL_FORM_HILITE);
|
||||
}
|
||||
}
|
||||
|
||||
void W_SLIDER::setTip(QString string)
|
||||
{
|
||||
pTip = string;
|
||||
}
|
||||
|
|
|
@ -32,34 +32,27 @@
|
|||
#define SLD_HILITE 0x0002 // Slider is hilited
|
||||
|
||||
|
||||
struct W_SLIDER : public WIDGET
|
||||
class W_SLIDER : public WIDGET
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
W_SLIDER(W_SLDINIT const *init);
|
||||
|
||||
void clicked(W_CONTEXT *psContext, WIDGET_KEY key);
|
||||
void released(W_CONTEXT *psContext, WIDGET_KEY key);
|
||||
void highlight(W_CONTEXT *psContext);
|
||||
void highlightLost(W_CONTEXT *psContext);
|
||||
void highlightLost();
|
||||
void run(W_CONTEXT *psContext);
|
||||
void display(int xOffset, int yOffset);
|
||||
|
||||
void setTip(QString string);
|
||||
|
||||
WSLD_ORIENTATION orientation; // The orientation of the slider
|
||||
UWORD numStops; // Number of stop positions on the slider
|
||||
UWORD barSize; // Thickness of slider bar
|
||||
UWORD pos; // Current stop position of the slider
|
||||
UWORD state; // Slider state
|
||||
const char *pTip; // Tool tip
|
||||
QString pTip; // Tool tip
|
||||
};
|
||||
|
||||
/* Create a slider widget data structure */
|
||||
extern W_SLIDER *sliderCreate(const W_SLDINIT *psInit);
|
||||
|
||||
/* Free the memory used by a slider */
|
||||
extern void sliderFree(W_SLIDER *psWidget);
|
||||
|
||||
/* Initialise a slider widget before running it */
|
||||
extern void sliderInitialise(W_SLIDER *psWidget);
|
||||
|
||||
/* The slider display function */
|
||||
extern void sliderDisplay(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
|
||||
#endif // __INCLUDED_LIB_WIDGET_SLIDER_H__
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "tip.h"
|
||||
// FIXME Direct iVis implementation include!
|
||||
#include "lib/ivis_opengl/pieblitfunc.h"
|
||||
#include <QtCore/QStringList>
|
||||
|
||||
/* Time delay before showing the tool tip */
|
||||
#define TIP_PAUSE 200
|
||||
|
@ -55,8 +56,8 @@ static SDWORD mx, my; // Last mouse coords
|
|||
static SDWORD wx, wy, ww, wh; // Position and size of button to place tip by
|
||||
static SDWORD tx, ty, tw, th; // Position and size of the tip box
|
||||
static SDWORD fx, fy; // Position of the text
|
||||
static const char *pTip; // Tip text
|
||||
static PIELIGHT *pColours; // The colours for the tool tip
|
||||
static int lineHeight;
|
||||
static QStringList pTip; // Tip text
|
||||
static WIDGET *psWidget; // The button the tip is for
|
||||
static enum iV_fonts FontID = font_regular; // ID for the Ivis Font.
|
||||
static PIELIGHT TipColour;
|
||||
|
@ -85,15 +86,9 @@ void widgSetTipColour(PIELIGHT colour)
|
|||
* x,y,width,height - specify the position of the button to place the
|
||||
* tip by.
|
||||
*/
|
||||
void tipStart(WIDGET *psSource, const char *pNewTip, enum iV_fonts NewFontID,
|
||||
PIELIGHT *pNewColours, SDWORD x, SDWORD y, UDWORD width, UDWORD height)
|
||||
void tipStart(WIDGET *psSource, QString pNewTip, iV_fonts NewFontID, int x, int y, int width, int height)
|
||||
{
|
||||
ASSERT(psSource != NULL,
|
||||
"tipStart: Invalid widget pointer");
|
||||
// ASSERT( pNewTip != NULL,
|
||||
// "tipStart: Invalid tip pointer" );
|
||||
ASSERT(pNewColours != NULL,
|
||||
"tipStart: Invalid colours pointer");
|
||||
ASSERT(psSource != NULL, "Invalid widget pointer");
|
||||
|
||||
tipState = TIP_WAIT;
|
||||
startTime = wzGetTicks();
|
||||
|
@ -101,10 +96,9 @@ void tipStart(WIDGET *psSource, const char *pNewTip, enum iV_fonts NewFontID,
|
|||
my = mouseY();
|
||||
wx = x; wy = y;
|
||||
ww = width; wh = height;
|
||||
pTip = pNewTip;
|
||||
pTip = pNewTip.split('\n');
|
||||
psWidget = psSource;
|
||||
FontID = NewFontID;
|
||||
pColours = pNewColours;
|
||||
}
|
||||
|
||||
|
||||
|
@ -122,13 +116,8 @@ void tipStop(WIDGET *psSource)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#define RIGHTBORDER (0)
|
||||
#define BOTTOMBORDER (0)
|
||||
|
||||
|
||||
/* Update and possibly display the tip */
|
||||
void tipDisplay(void)
|
||||
void tipDisplay()
|
||||
{
|
||||
SDWORD newMX, newMY;
|
||||
SDWORD currTime;
|
||||
|
@ -152,39 +141,28 @@ void tipDisplay(void)
|
|||
topGap = TIP_VGAP;
|
||||
iV_SetFont(FontID);
|
||||
|
||||
fw = iV_GetTextWidth(pTip);
|
||||
lineHeight = iV_GetTextLineSize();
|
||||
|
||||
fw = 0;
|
||||
for (int n = 0; n < pTip.size(); ++n)
|
||||
{
|
||||
fw = std::max<int>(fw, iV_GetTextWidth(pTip[n].toUtf8().constData()));
|
||||
}
|
||||
tw = fw + TIP_HGAP * 2;
|
||||
th = topGap * 2 + iV_GetTextLineSize() + iV_GetTextBelowBase();
|
||||
th = topGap * 2 + lineHeight*pTip.size() + iV_GetTextBelowBase();
|
||||
|
||||
/* Position the tip box */
|
||||
tx = wx + (ww >> 1);
|
||||
ty = wy + wh + TIP_VGAP;
|
||||
|
||||
/* Check the box is on screen */
|
||||
if (tx < 0)
|
||||
{
|
||||
tx = 0;
|
||||
}
|
||||
if (tx + tw >= (SDWORD)screenWidth - RIGHTBORDER)
|
||||
{
|
||||
tx = screenWidth - RIGHTBORDER - tw - 1;
|
||||
}
|
||||
if (ty < 0)
|
||||
{
|
||||
ty = 0;
|
||||
}
|
||||
if (ty + th >= (SDWORD)screenHeight - BOTTOMBORDER)
|
||||
tx = clip(wx + ww/2, 0, screenWidth - tw - 1);
|
||||
ty = std::max(wy + wh + TIP_VGAP, 0);
|
||||
if (ty + th >= (int)screenHeight)
|
||||
{
|
||||
/* Position the tip above the button */
|
||||
ty = wy - th - TIP_VGAP;
|
||||
}
|
||||
|
||||
|
||||
/* Position the text */
|
||||
fx = tx + TIP_HGAP;
|
||||
|
||||
fy = ty + (th - iV_GetTextLineSize()) / 2 - iV_GetTextAboveBase();
|
||||
|
||||
fy = ty + (th - lineHeight*pTip.size()) / 2 - iV_GetTextAboveBase();
|
||||
|
||||
/* Note the time */
|
||||
startTime = wzGetTicks();
|
||||
|
@ -200,16 +178,19 @@ void tipDisplay(void)
|
|||
break;
|
||||
case TIP_ACTIVE:
|
||||
/* Draw the tool tip */
|
||||
pie_BoxFill(tx, ty, tx + tw, ty + th, pColours[WCOL_TIPBKGRND]);
|
||||
iV_Line(tx + 1, ty + th - 2, tx + 1, ty + 1, pColours[WCOL_DARK]);
|
||||
iV_Line(tx + 2, ty + 1, tx + tw - 2, ty + 1, pColours[WCOL_DARK]);
|
||||
iV_Line(tx, ty + th, tx + tw, ty + th, pColours[WCOL_DARK]);
|
||||
iV_Line(tx + tw, ty + th - 1, tx + tw, ty, pColours[WCOL_DARK]);
|
||||
iV_Box(tx, ty, tx + tw - 1, ty + th - 1, pColours[WCOL_LIGHT]);
|
||||
pie_BoxFill(tx, ty, tx + tw, ty + th, WZCOL_FORM_TIP_BACKGROUND);
|
||||
iV_Line(tx + 1, ty + th - 2, tx + 1, ty + 1, WZCOL_FORM_DARK);
|
||||
iV_Line(tx + 2, ty + 1, tx + tw - 2, ty + 1, WZCOL_FORM_DARK);
|
||||
iV_Line(tx, ty + th, tx + tw, ty + th, WZCOL_FORM_DARK);
|
||||
iV_Line(tx + tw, ty + th - 1, tx + tw, ty, WZCOL_FORM_DARK);
|
||||
iV_Box(tx, ty, tx + tw - 1, ty + th - 1, WZCOL_FORM_LIGHT);
|
||||
|
||||
iV_SetFont(FontID);
|
||||
iV_SetTextColour(TipColour);
|
||||
iV_DrawText(pTip, fx, fy);
|
||||
for (int n = 0; n < pTip.size(); ++n)
|
||||
{
|
||||
iV_DrawText(pTip[n].toUtf8().constData(), fx, fy + lineHeight*n);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -41,8 +41,7 @@ extern void tipInitialise(void);
|
|||
* x,y,width,height - specify the position of the button to place the
|
||||
* tip by.
|
||||
*/
|
||||
extern void tipStart(WIDGET *psSource, const char *pTip, enum iV_fonts NewFontID,
|
||||
PIELIGHT *pColours, SDWORD x, SDWORD y, UDWORD width, UDWORD height);
|
||||
void tipStart(WIDGET *psSource, QString pTip, iV_fonts NewFontID, int x, int y, int width, int height);
|
||||
|
||||
/* Stop a tool tip (e.g. if the hilite is lost on a button).
|
||||
* psSource should be the same as the widget that started the tip.
|
||||
|
|
|
@ -27,21 +27,24 @@
|
|||
#include "lib/framework/frame.h"
|
||||
#include "lib/ivis_opengl/piedef.h"
|
||||
#include "lib/ivis_opengl/textdraw.h"
|
||||
#include <QtCore/QRect>
|
||||
#include <QtCore/QObject>
|
||||
|
||||
|
||||
/* Forward definitions */
|
||||
struct WIDGET;
|
||||
class WIDGET;
|
||||
struct W_CONTEXT;
|
||||
struct W_FORM;
|
||||
class W_FORM;
|
||||
struct W_INIT;
|
||||
struct W_SCREEN;
|
||||
struct W_EDITBOX;
|
||||
struct W_BARGRAPH;
|
||||
struct W_BUTTON;
|
||||
struct W_LABEL;
|
||||
class W_EDITBOX;
|
||||
class W_BARGRAPH;
|
||||
class W_BUTTON;
|
||||
class W_LABEL;
|
||||
class W_SLIDER;
|
||||
|
||||
/* The display function prototype */
|
||||
typedef void (*WIDGET_DISPLAY)(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
typedef void (*WIDGET_DISPLAY)(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset);
|
||||
|
||||
/* The optional user callback function */
|
||||
typedef void (*WIDGET_CALLBACK)(WIDGET *psWidget, W_CONTEXT *psContext);
|
||||
|
@ -57,6 +60,7 @@ enum WIDGET_TYPE
|
|||
WIDG_EDITBOX,
|
||||
WIDG_BARGRAPH,
|
||||
WIDG_SLIDER,
|
||||
WIDG_UNSPECIFIED_TYPE,
|
||||
};
|
||||
|
||||
/* The keys that can be used to press a button */
|
||||
|
@ -67,31 +71,95 @@ enum WIDGET_KEY
|
|||
WKEY_SECONDARY,
|
||||
};
|
||||
|
||||
/* The base widget data type */
|
||||
struct WIDGET
|
||||
enum
|
||||
{
|
||||
WIDG_HIDDEN = 0x8000, ///< The widget is initially hidden
|
||||
};
|
||||
|
||||
/* The base widget data type */
|
||||
class WIDGET : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
typedef std::vector<WIDGET *> Children;
|
||||
|
||||
WIDGET(W_INIT const *init, WIDGET_TYPE type);
|
||||
virtual ~WIDGET() {}
|
||||
WIDGET(WIDGET *parent, WIDGET_TYPE type = WIDG_UNSPECIFIED_TYPE);
|
||||
virtual ~WIDGET();
|
||||
|
||||
void deleteLater(); ///< Like "delete this;", but safe to call from display/run callbacks.
|
||||
|
||||
virtual void widgetLost(WIDGET *);
|
||||
|
||||
virtual void clicked(W_CONTEXT *, WIDGET_KEY = WKEY_PRIMARY) {}
|
||||
virtual void released(W_CONTEXT *, WIDGET_KEY = WKEY_PRIMARY) {}
|
||||
virtual void highlight(W_CONTEXT *) {}
|
||||
virtual void highlightLost(W_CONTEXT *) {}
|
||||
virtual void focusLost(W_SCREEN *) {}
|
||||
virtual void highlightLost() {}
|
||||
virtual void focusLost() {}
|
||||
virtual void run(W_CONTEXT *) {}
|
||||
virtual void display(int, int) {}
|
||||
virtual void geometryChanged() {}
|
||||
|
||||
virtual unsigned getState();
|
||||
virtual void setState(unsigned state);
|
||||
virtual void setFlash(bool enable);
|
||||
virtual QString getString() const;
|
||||
virtual void setString(QString string);
|
||||
virtual void setTip(QString string);
|
||||
|
||||
void show(bool doShow = true) { style = (style & ~WIDG_HIDDEN) | (!doShow*WIDG_HIDDEN); }
|
||||
void hide() { show(false); }
|
||||
bool visible() { return (style & WIDG_HIDDEN) == 0; }
|
||||
|
||||
void setString(char const *stringUtf8) { setString(QString::fromUtf8(stringUtf8)); }
|
||||
void setTip(char const *stringUtf8) { setTip(QString::fromUtf8(stringUtf8)); }
|
||||
|
||||
WIDGET *parent() { return parentWidget; }
|
||||
Children const &children() { return childWidgets; }
|
||||
QRect const &geometry() const { return dim; }
|
||||
int x() const { return dim.x(); }
|
||||
int y() const { return dim.y(); }
|
||||
int width() const { return dim.width(); }
|
||||
int height() const { return dim.height(); }
|
||||
void move(int x, int y) { setGeometry(QRect(x, y, width(), height())); }
|
||||
void setGeometry(int x, int y, int w, int h) { setGeometry(QRect(x, y, w, h)); }
|
||||
void setGeometry(QRect const &r);
|
||||
|
||||
void attach(WIDGET *widget);
|
||||
void detach(WIDGET *widget);
|
||||
|
||||
UDWORD formID; ///< ID of the widgets base form.
|
||||
UDWORD id; ///< The user set ID number for the widget. This is returned when e.g. a button is pressed.
|
||||
WIDGET_TYPE type; ///< The widget type
|
||||
UDWORD style; ///< The style of the widget
|
||||
SWORD x, y; ///< The location of the widget
|
||||
UWORD width, height; ///< The size of the widget
|
||||
WIDGET_DISPLAY display; ///< Display the widget
|
||||
WIDGET_DISPLAY displayFunction; ///< Override function to display the widget.
|
||||
WIDGET_CALLBACK callback; ///< User callback (if any)
|
||||
void *pUserData; ///< Pointer to a user data block (if any)
|
||||
UDWORD UserData; ///< User data (if any)
|
||||
W_SCREEN * screenPointer; ///< Pointer to screen the widget is on (if attached).
|
||||
|
||||
WIDGET *psNext; ///< Pointer to the next widget in the screen list
|
||||
private:
|
||||
void setScreenPointer(W_SCREEN *screen); ///< Set screen pointer for us and all children.
|
||||
public:
|
||||
void processClickRecursive(W_CONTEXT *psContext, WIDGET_KEY key, bool wasPressed);
|
||||
void runRecursive(W_CONTEXT *psContext);
|
||||
void processCallbacksRecursive(W_CONTEXT *psContext);
|
||||
void displayRecursive(int xOffset, int yOffset); ///< Display this widget, and all visible children.
|
||||
private:
|
||||
|
||||
WIDGET * parentWidget; ///< Parent widget.
|
||||
std::vector<WIDGET *> childWidgets; ///< Child widgets. Will be deleted if we are deleted.
|
||||
|
||||
QRect dim;
|
||||
|
||||
private:
|
||||
#ifdef WZ_CXX11
|
||||
WIDGET(WIDGET const &) = delete;
|
||||
WIDGET &operator =(WIDGET const &) = delete;
|
||||
#else
|
||||
WIDGET(WIDGET const &); // Non-copyable.
|
||||
WIDGET &operator =(WIDGET const &); // Non-copyable.
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
@ -104,17 +172,31 @@ typedef std::vector<WidgetTrigger> WidgetTriggers;
|
|||
/* The screen structure which stores all info for a widget screen */
|
||||
struct W_SCREEN
|
||||
{
|
||||
W_SCREEN();
|
||||
~W_SCREEN();
|
||||
|
||||
void setFocus(WIDGET *widget); ///< Sets psFocus, notifying the old widget, if any.
|
||||
void setReturn(WIDGET *psWidget); ///< Adds psWidget to retWidgets.
|
||||
|
||||
W_FORM *psForm; ///< The root form of the screen
|
||||
WIDGET *psFocus; ///< The widget that has keyboard focus
|
||||
enum iV_fonts TipFontID; ///< ID of the IVIS font to use for tool tips.
|
||||
WIDGET * lastHighlight; ///< The last widget to be highlighted. This is used to track when the mouse moves off something.
|
||||
iV_fonts TipFontID; ///< ID of the IVIS font to use for tool tips.
|
||||
WidgetTriggers retWidgets; ///< The widgets to be returned by widgRunScreen.
|
||||
|
||||
private:
|
||||
#ifdef WZ_CXX11
|
||||
W_SCREEN(W_SCREEN const &) = delete;
|
||||
W_SCREEN &operator =(W_SCREEN const &) = delete;
|
||||
#else
|
||||
W_SCREEN(W_SCREEN const &); // Non-copyable.
|
||||
W_SCREEN &operator =(W_SCREEN const &); // Non-copyable.
|
||||
#endif
|
||||
};
|
||||
|
||||
/* Context information to pass into the widget functions */
|
||||
struct W_CONTEXT
|
||||
{
|
||||
W_SCREEN *psScreen; // Parent screen of the widget
|
||||
W_FORM *psForm; ///< Parent form of the widget
|
||||
SDWORD xOffset, yOffset; // Screen offset of the parent form
|
||||
SDWORD mx, my; // mouse position on the form
|
||||
};
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -40,14 +40,11 @@
|
|||
* Widget style definitions - these control how the basic widget appears on screen
|
||||
*/
|
||||
|
||||
#define WIDG_HIDDEN 0x8000 ///< The widget is initially hidden
|
||||
|
||||
/************ Form styles ****************/
|
||||
|
||||
#define WFORM_PLAIN 0 ///< Plain form
|
||||
#define WFORM_TABBED 1 ///< Tabbed form
|
||||
|
||||
/** Invisible (i.e. see through) form - can be used in conjunction with WFORM_PLAIN or WFORM_TABBED. */
|
||||
/** Invisible (i.e. see through) form - can be used in conjunction with WFORM_PLAIN. */
|
||||
#define WFORM_INVISIBLE 2
|
||||
|
||||
#define WFORM_CLICKABLE 4 ///< Clickable form - return form id when the form is clicked
|
||||
|
@ -63,14 +60,22 @@
|
|||
/************ Label styles ***************/
|
||||
|
||||
#define WLAB_PLAIN 0 ///< Plain text only label
|
||||
#define WLAB_ALIGNLEFT 1 ///< Align the text at the left of the box
|
||||
#define WLAB_ALIGNCENTRE 2 ///< Center the text
|
||||
#define WLAB_ALIGNRIGHT 4 ///< Align the text at the right of the box
|
||||
enum WzTextAlignment
|
||||
{
|
||||
WLAB_ALIGNLEFT = 0, ///< Align the text at the left of the box
|
||||
WLAB_ALIGNCENTRE = 1, ///< Centre the text
|
||||
WLAB_ALIGNRIGHT = 2, ///< Align the text at the right of the box
|
||||
WLAB_ALIGNTOPLEFT = 4, ///< Align the text at the top left of the box
|
||||
WLAB_ALIGNTOP = 4 + 1, ///< Align the text at the top of the box
|
||||
WLAB_ALIGNTOPRIGHT = 4 + 2, ///< Align the text at the top right of the box
|
||||
WLAB_ALIGNBOTTOMLEFT = 8, ///< Align the text at the bottom left of the box
|
||||
WLAB_ALIGNBOTTOM = 8 + 1, ///< Align the text at the bottom of the box
|
||||
WLAB_ALIGNBOTTOMRIGHT = 8 + 2, ///< Align the text at the bottom rightof the box
|
||||
};
|
||||
|
||||
/************ Button styles **************/
|
||||
|
||||
#define WBUT_PLAIN 0 ///< Plain button (text with a box around it)
|
||||
#define WBUT_NOCLICKMOVE 8 ///< Disable movement on a button
|
||||
|
||||
|
||||
/**
|
||||
|
@ -103,7 +108,7 @@ struct W_INIT
|
|||
W_INIT();
|
||||
|
||||
UDWORD formID; ///< ID number of form to put widget on. ID == 0 specifies the default form for the screen
|
||||
UWORD majorID, minorID; ///< Which major and minor tab to put the widget on for a tabbed form
|
||||
UWORD majorID; ///< Which tab to put the widget on for a tabbed form
|
||||
UDWORD id; ///< Unique id number (chosen by user)
|
||||
UDWORD style; ///< widget style
|
||||
SWORD x, y; ///< screen location
|
||||
|
@ -114,65 +119,13 @@ struct W_INIT
|
|||
UDWORD UserData; ///< User data (if any)
|
||||
};
|
||||
|
||||
/*
|
||||
* Flags for controlling where the tabs appear on a form -
|
||||
* used in the majorPos and minorPos entries of the W_FORMINIT struct
|
||||
*/
|
||||
#define WFORM_TABNONE 0 ///< No tab
|
||||
#define WFORM_TABTOP 1
|
||||
#define WFORM_TABLEFT 2
|
||||
#define WFORM_TABRIGHT 3
|
||||
#define WFORM_TABBOTTOM 4
|
||||
|
||||
/*
|
||||
* Upper limits for major and minor tabs on a tab form.
|
||||
* Not the best way to do it I know, but it keeps the memory
|
||||
* management MUCH simpler.
|
||||
*/
|
||||
|
||||
// The below define is max # of tabs we can have.
|
||||
// It is set to 20 Look @ #define MAXSTRUCTURES 200 in hci.h Keep them in check!
|
||||
// New routines really have no max limit. I am not sure what max # a legal user can have.
|
||||
#define WFORM_MAXMAJOR 40 // Maximum number of major tabs on a tab form
|
||||
// we do NOT use MAX MINOR now, it is another way to draw the widgets.
|
||||
#define WFORM_MAXMINOR 5 //15 // Maximum number of minor tabs off a major
|
||||
#define MAX_TAB_STD_SHOWN 4 // max # of tabs we can display using standard tab icons.
|
||||
#define MAX_TAB_SMALL_SHOWN 8 // max # of tabs we can display using small tab icons.
|
||||
#define TAB_SEVEN 7 //*with* tab scroll buttons, we can only (currently) show 7 max!
|
||||
// NOTE: enable TAB_MINOR at your own risk. Have NOT testest new rotuines with that.
|
||||
#define TAB_MINOR 0 // Tab types passed into tab display callbacks.
|
||||
#define TAB_MAJOR 1
|
||||
|
||||
typedef void (*TAB_DISPLAY)(WIDGET *psWidget, UDWORD TabType, UDWORD Position, UDWORD Number, bool Selected, bool Hilight, UDWORD x, UDWORD y, UDWORD Width, UDWORD Height);
|
||||
typedef void (*FONT_DISPLAY)(UDWORD x, UDWORD y, char *String);
|
||||
|
||||
/** Form initialisation structure */
|
||||
struct W_FORMINIT : public W_INIT
|
||||
{
|
||||
W_FORMINIT();
|
||||
|
||||
/* Data for a tabbed form */
|
||||
bool disableChildren;
|
||||
UWORD majorPos, minorPos; // Position of the tabs on the form
|
||||
UWORD majorSize, minorSize; // Size of the tabs (in pixels)
|
||||
SWORD majorOffset, minorOffset; // Tab start offset.
|
||||
SWORD tabVertOffset; ///< Tab form overlap offset.
|
||||
SWORD tabHorzOffset; ///< Tab form overlap offset.
|
||||
UWORD tabMajorThickness; ///< The thickness of the tabs
|
||||
UWORD tabMinorThickness; ///< The thickness of the tabs
|
||||
UWORD tabMajorGap; ///< The space between tabs
|
||||
UWORD tabMinorGap; ///< The space between tabs
|
||||
UWORD numStats; ///< Number of "stats" (items) in list
|
||||
UWORD numButtons; ///< Number of buttons per form
|
||||
UWORD numMajor; ///< Number of major tabs
|
||||
UWORD aNumMinors[WFORM_MAXMAJOR]; ///< Number of minor tabs for each major
|
||||
SWORD TabMultiplier; ///< Used to tell system we got lots of (virtual) tabs to display
|
||||
unsigned maxTabsShown; ///< Maximum number of tabs shown at once.
|
||||
const char *pTip; ///< Tool tip for the form itself
|
||||
char *apMajorTips[WFORM_MAXMAJOR]; ///< Tool tips for the major tabs
|
||||
char *apMinorTips[WFORM_MAXMAJOR][WFORM_MAXMINOR]; ///< Tool tips for the minor tabs
|
||||
TAB_DISPLAY pTabDisplay; ///< Optional callback for displaying a tab.
|
||||
WIDGET_DISPLAY pFormDisplay; ///< Optional callback to display the form.
|
||||
};
|
||||
|
||||
/** Label initialisation structure */
|
||||
|
@ -203,7 +156,6 @@ struct W_EDBINIT : public W_INIT
|
|||
const char *pText; ///< initial contents of the edit box
|
||||
enum iV_fonts FontID; ///< ID of the IVIS font to use for this widget.
|
||||
WIDGET_DISPLAY pBoxDisplay; ///< Optional callback to display the form.
|
||||
FONT_DISPLAY pFontDisplay; ///< Optional callback to display a string.
|
||||
};
|
||||
|
||||
/* Orientation flags for the bar graph */
|
||||
|
@ -255,9 +207,6 @@ struct W_SLDINIT : public W_INIT
|
|||
|
||||
/***********************************************************************************/
|
||||
|
||||
/** The maximum lenth of strings for the widget system */
|
||||
#define WIDG_MAXSTR 80
|
||||
|
||||
/** The maximum value for bar graph size */
|
||||
#define WBAR_SCALE 100
|
||||
|
||||
|
@ -270,32 +219,23 @@ extern void widgReset(void);
|
|||
/** Shut down the widget module */
|
||||
extern void widgShutDown(void);
|
||||
|
||||
/** Create an empty widget screen */
|
||||
extern W_SCREEN *widgCreateScreen(void);
|
||||
|
||||
/** Release a screen and all its associated data */
|
||||
extern void widgReleaseScreen(W_SCREEN *psScreen);
|
||||
|
||||
/** Set the tool tip font for a screen */
|
||||
extern void widgSetTipFont(W_SCREEN *psScreen, enum iV_fonts FontID);
|
||||
|
||||
/** Add a form to the widget screen */
|
||||
extern bool widgAddForm(W_SCREEN *psScreen, const W_FORMINIT *psInit);
|
||||
W_FORM *widgAddForm(W_SCREEN *psScreen, const W_FORMINIT *psInit);
|
||||
|
||||
/** Add a label to the widget screen */
|
||||
extern bool widgAddLabel(W_SCREEN *psScreen, const W_LABINIT *psInit);
|
||||
W_LABEL *widgAddLabel(W_SCREEN *psScreen, const W_LABINIT *psInit);
|
||||
|
||||
/** Add a button to a form */
|
||||
extern bool widgAddButton(W_SCREEN *psScreen, const W_BUTINIT *psInit);
|
||||
W_BUTTON *widgAddButton(W_SCREEN *psScreen, const W_BUTINIT *psInit);
|
||||
|
||||
/** Add an edit box to a form */
|
||||
extern bool widgAddEditBox(W_SCREEN *psScreen, const W_EDBINIT *psInit);
|
||||
W_EDITBOX *widgAddEditBox(W_SCREEN *psScreen, const W_EDBINIT *psInit);
|
||||
|
||||
/** Add a bar graph to a form */
|
||||
extern bool widgAddBarGraph(W_SCREEN *psScreen, const W_BARINIT *psInit);
|
||||
W_BARGRAPH *widgAddBarGraph(W_SCREEN *psScreen, const W_BARINIT *psInit);
|
||||
|
||||
/** Add a slider to a form */
|
||||
extern bool widgAddSlider(W_SCREEN *psScreen, const W_SLDINIT *psInit);
|
||||
W_SLIDER *widgAddSlider(W_SCREEN *psScreen, const W_SLDINIT *psInit);
|
||||
|
||||
/** Delete a widget from the screen */
|
||||
extern void widgDelete(W_SCREEN *psScreen, UDWORD id);
|
||||
|
@ -315,18 +255,6 @@ extern const char *widgGetString(W_SCREEN *psScreen, UDWORD id);
|
|||
/** Set the text in a widget */
|
||||
extern void widgSetString(W_SCREEN *psScreen, UDWORD id, const char *pText);
|
||||
|
||||
/** Set the current tabs for a tab form */
|
||||
extern void widgSetTabs(W_SCREEN *psScreen, UDWORD id, UWORD major, UWORD minor);
|
||||
|
||||
/** Get the current tabs for a tab form */
|
||||
extern void widgGetTabs(W_SCREEN *psScreen, UDWORD id, UWORD *pMajor, UWORD *pMinor);
|
||||
|
||||
/** Get the number of major tab in a tab form. */
|
||||
int widgGetNumTabMajor(W_SCREEN *psScreen, UDWORD id);
|
||||
|
||||
/** Get the number of minor tabs in a tab form. */
|
||||
int widgGetNumTabMinor(W_SCREEN *psScreen, UDWORD id, UWORD pMajor);
|
||||
|
||||
/** Get the current position of a widget */
|
||||
extern void widgGetPos(W_SCREEN *psScreen, UDWORD id, SWORD *pX, SWORD *pY);
|
||||
|
||||
|
@ -362,7 +290,6 @@ extern WIDGET *widgGetFromID(W_SCREEN *psScreen, UDWORD id);
|
|||
|
||||
/** Set tip string for a widget */
|
||||
extern void widgSetTip(W_SCREEN *psScreen, UDWORD id, const char *pTip);
|
||||
extern void widgSetTipText(WIDGET *psWidget, const char *pTip);
|
||||
|
||||
/** Colour numbers */
|
||||
enum _w_colour
|
||||
|
@ -379,17 +306,20 @@ enum _w_colour
|
|||
WCOL_MAX, ///< All colour numbers are less than this
|
||||
};
|
||||
|
||||
/** Set a colour on a form */
|
||||
extern void widgSetColour(W_SCREEN *psScreen, UDWORD id, UDWORD index, PIELIGHT colour);
|
||||
|
||||
/** Set the global toop tip text colour. */
|
||||
extern void widgSetTipColour(PIELIGHT colour);
|
||||
|
||||
/* Possible states for a button */
|
||||
#define WBUT_DISABLE 0x0001 ///< Disable (grey out) a button
|
||||
#define WBUT_LOCK 0x0002 ///< Fix a button down
|
||||
#define WBUT_CLICKLOCK 0x0004 ///< Fix a button down but it is still clickable
|
||||
#define WBUT_FLASH 0x0008 ///< Make a button flash.
|
||||
// Possible states for a button or clickform.
|
||||
enum ButtonState
|
||||
{
|
||||
WBUT_DISABLE = 0x01, ///< Disable (grey out) a button.
|
||||
WBUT_LOCK = 0x02, ///< Fix a button down.
|
||||
WBUT_CLICKLOCK = 0x04, ///< Fix a button down but it is still clickable.
|
||||
WBUT_FLASH = 0x08, ///< Make a button flash.
|
||||
WBUT_DOWN = 0x10, ///< Button is down.
|
||||
WBUT_HIGHLIGHT = 0x20, ///< Button is highlighted.
|
||||
};
|
||||
|
||||
|
||||
extern void widgSetButtonFlash(W_SCREEN *psScreen, UDWORD id);
|
||||
extern void widgClearButtonFlash(W_SCREEN *psScreen, UDWORD id);
|
||||
|
@ -404,18 +334,6 @@ extern void widgSetButtonState(W_SCREEN *psScreen, UDWORD id, UDWORD state);
|
|||
/** Return which key was used to press the last returned widget */
|
||||
extern UDWORD widgGetButtonKey_DEPRECATED(W_SCREEN *psScreen);
|
||||
|
||||
/** Initialise the set of widgets that make up a screen.
|
||||
* Call this once before calling widgRunScreen and widgDisplayScreen.
|
||||
* This should only be called once before calling Run and Display as many times
|
||||
* as is required.
|
||||
*/
|
||||
extern void widgStartScreen(W_SCREEN *psScreen);
|
||||
|
||||
/** Clean up after a screen has been run.
|
||||
* Call this after the widgRunScreen / widgDisplayScreen cycle.
|
||||
*/
|
||||
extern void widgEndScreen(W_SCREEN *psScreen);
|
||||
|
||||
/** Execute a set of widgets for one cycle.
|
||||
* Return the id of the widget that was activated, or 0 for none.
|
||||
*/
|
||||
|
@ -446,7 +364,6 @@ extern void sliderEnableDrag(bool Enable);
|
|||
extern void setWidgetsStatus(bool var);
|
||||
extern bool getWidgetsStatus(void);
|
||||
|
||||
extern void CheckpsMouseOverWidget(void *psWidget);
|
||||
/** @} */
|
||||
|
||||
#endif // __INCLUDED_LIB_WIDGET_WIDGET_H__
|
||||
|
|
|
@ -194,6 +194,7 @@
|
|||
<ClCompile Include="editbox.cpp" />
|
||||
<ClCompile Include="form.cpp" />
|
||||
<ClCompile Include="label.cpp" />
|
||||
<ClCompile Include="listwidget.cpp" />
|
||||
<ClCompile Include="slider.cpp" />
|
||||
<ClCompile Include="tip.cpp" />
|
||||
<ClCompile Include="widget.cpp" />
|
||||
|
@ -204,6 +205,7 @@
|
|||
<ClInclude Include="editbox.h" />
|
||||
<ClInclude Include="form.h" />
|
||||
<ClInclude Include="label.h" />
|
||||
<ClInclude Include="listwidget.h" />
|
||||
<ClInclude Include="slider.h" />
|
||||
<ClInclude Include="tip.h" />
|
||||
<ClInclude Include="widgbase.h" />
|
||||
|
|
|
@ -25,18 +25,6 @@
|
|||
#define __INCLUDED_LIB_WIDGET_WIDGINT_H__
|
||||
|
||||
#include "lib/framework/input.h"
|
||||
#include "widgbase.h"
|
||||
|
||||
/* Set the id number for widgRunScreen to return */
|
||||
extern void widgSetReturn(W_SCREEN *psScreen, WIDGET *psWidget);
|
||||
|
||||
/* Release a list of widgets */
|
||||
extern void widgReleaseWidgetList(WIDGET *psWidgets);
|
||||
|
||||
/* Set the keyboard focus for the screen */
|
||||
extern void screenSetFocus(W_SCREEN *psScreen, WIDGET *psWidget);
|
||||
|
||||
/* Clear the keyboard focus */
|
||||
extern void screenClearFocus(W_SCREEN *psScreen);
|
||||
//#include "widgbase.h"
|
||||
|
||||
#endif // __INCLUDED_LIB_WIDGET_WIDGINT_H__
|
||||
|
|
|
@ -2,7 +2,9 @@ AM_CPPFLAGS = -DYY_NO_INPUT $(SDL_CFLAGS) $(PHYSFS_CFLAGS) $(PNG_CFLAGS) $(VORBI
|
|||
AM_CFLAGS = $(WZ_CFLAGS)
|
||||
AM_CXXFLAGS = $(WZ_CXXFLAGS) $(QT4_CFLAGS)
|
||||
|
||||
MOCHEADER = qtscriptdebug.h
|
||||
MOCHEADER = \
|
||||
multiint.h \
|
||||
qtscriptdebug.h
|
||||
MOCEDFILES = $(MOCHEADER:%.h=%_moc.cpp)
|
||||
|
||||
%_moc.cpp: %.h
|
||||
|
@ -122,7 +124,6 @@ noinst_HEADERS = \
|
|||
projectiledef.h \
|
||||
projectile.h \
|
||||
qtscript.h \
|
||||
qtscriptdebug.h \
|
||||
qtscriptfuncs.h \
|
||||
radar.h \
|
||||
random.h \
|
||||
|
@ -160,6 +161,7 @@ noinst_HEADERS = \
|
|||
$(MOCHEADER)
|
||||
|
||||
nodist_warzone2100_SOURCES = \
|
||||
multiint_moc.cpp \
|
||||
qtscriptdebug_moc.cpp
|
||||
|
||||
warzone2100_SOURCES = \
|
||||
|
|
|
@ -80,14 +80,14 @@ static W_SCREEN *psRequestScreen; // Widget screen for requester
|
|||
bool challengesUp = false; ///< True when interface is up and should be run.
|
||||
bool challengeActive = false; ///< Whether we are running a challenge
|
||||
|
||||
static void displayLoadBanner(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours)
|
||||
static void displayLoadBanner(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
|
||||
{
|
||||
PIELIGHT col = WZCOL_GREEN;
|
||||
UDWORD x = xOffset + psWidget->x;
|
||||
UDWORD y = yOffset + psWidget->y;
|
||||
UDWORD x = xOffset + psWidget->x();
|
||||
UDWORD y = yOffset + psWidget->y();
|
||||
|
||||
pie_BoxFill(x, y, x + psWidget->width, y + psWidget->height, col);
|
||||
pie_BoxFill(x + 2, y + 2, x + psWidget->width - 2, y + psWidget->height - 2, WZCOL_MENU_BACKGROUND);
|
||||
pie_BoxFill(x, y, x + psWidget->width(), y + psWidget->height(), col);
|
||||
pie_BoxFill(x + 2, y + 2, x + psWidget->width() - 2, y + psWidget->height() - 2, WZCOL_MENU_BACKGROUND);
|
||||
}
|
||||
|
||||
// quite the hack, game name is stored in global sRequestResult
|
||||
|
@ -126,23 +126,23 @@ void updateChallenge(bool gameWon)
|
|||
}
|
||||
|
||||
// ////////////////////////////////////////////////////////////////////////////
|
||||
static void displayLoadSlot(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours)
|
||||
static void displayLoadSlot(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
|
||||
{
|
||||
|
||||
UDWORD x = xOffset + psWidget->x;
|
||||
UDWORD y = yOffset + psWidget->y;
|
||||
UDWORD x = xOffset + psWidget->x();
|
||||
UDWORD y = yOffset + psWidget->y();
|
||||
char butString[64];
|
||||
|
||||
drawBlueBox(x, y, psWidget->width, psWidget->height); //draw box
|
||||
drawBlueBox(x, y, psWidget->width(), psWidget->height()); //draw box
|
||||
|
||||
if (((W_BUTTON *)psWidget)->pText)
|
||||
if (!((W_BUTTON *)psWidget)->pText.isEmpty())
|
||||
{
|
||||
sstrcpy(butString, ((W_BUTTON *)psWidget)->pText);
|
||||
sstrcpy(butString, ((W_BUTTON *)psWidget)->pText.toUtf8().constData());
|
||||
|
||||
iV_SetFont(font_regular); // font
|
||||
iV_SetTextColour(WZCOL_FORM_TEXT);
|
||||
|
||||
while (iV_GetTextWidth(butString) > psWidget->width)
|
||||
while (iV_GetTextWidth(butString) > psWidget->width())
|
||||
{
|
||||
butString[strlen(butString)-1] = '\0';
|
||||
}
|
||||
|
@ -167,32 +167,24 @@ bool addChallenges()
|
|||
|
||||
(void) PHYSFS_mkdir(sSearchPath); // just in case
|
||||
|
||||
psRequestScreen = widgCreateScreen(); // init the screen
|
||||
widgSetTipFont(psRequestScreen, font_regular);
|
||||
psRequestScreen = new W_SCREEN; // init the screen
|
||||
|
||||
WIDGET *parent = psRequestScreen->psForm;
|
||||
|
||||
/* add a form to place the tabbed form on */
|
||||
W_FORMINIT sFormInit;
|
||||
sFormInit.formID = 0; //this adds the blue background, and the "box" behind the buttons -Q
|
||||
sFormInit.id = CHALLENGE_FORM;
|
||||
sFormInit.style = WFORM_PLAIN;
|
||||
sFormInit.x = (SWORD) CHALLENGE_X;
|
||||
sFormInit.y = (SWORD) CHALLENGE_Y;
|
||||
sFormInit.width = CHALLENGE_W;
|
||||
// we need the form to be long enough for all resolutions, so we take the total number of items * height
|
||||
// and * the gaps, add the banner, and finally, the fudge factor ;)
|
||||
sFormInit.height = (slotsInColumn * CHALLENGE_ENTRY_H + CHALLENGE_HGAP * slotsInColumn) + CHALLENGE_BANNER_DEPTH + 20;
|
||||
sFormInit.disableChildren = true;
|
||||
sFormInit.pDisplay = intOpenPlainForm;
|
||||
widgAddForm(psRequestScreen, &sFormInit);
|
||||
IntFormAnimated *challengeForm = new IntFormAnimated(parent);
|
||||
challengeForm->id = CHALLENGE_FORM;
|
||||
challengeForm->setGeometry(CHALLENGE_X, CHALLENGE_Y, CHALLENGE_W, (slotsInColumn * CHALLENGE_ENTRY_H + CHALLENGE_HGAP * slotsInColumn) + CHALLENGE_BANNER_DEPTH + 20);
|
||||
|
||||
// Add Banner
|
||||
W_FORMINIT sFormInit;
|
||||
sFormInit.formID = CHALLENGE_FORM;
|
||||
sFormInit.id = CHALLENGE_BANNER;
|
||||
sFormInit.style = WFORM_PLAIN;
|
||||
sFormInit.x = CHALLENGE_HGAP;
|
||||
sFormInit.y = CHALLENGE_VGAP;
|
||||
sFormInit.width = CHALLENGE_W - (2 * CHALLENGE_HGAP);
|
||||
sFormInit.height = CHALLENGE_BANNER_DEPTH;
|
||||
sFormInit.disableChildren = false;
|
||||
sFormInit.pDisplay = displayLoadBanner;
|
||||
sFormInit.UserData = 0;
|
||||
widgAddForm(psRequestScreen, &sFormInit);
|
||||
|
@ -334,8 +326,8 @@ bool addChallenges()
|
|||
// ////////////////////////////////////////////////////////////////////////////
|
||||
bool closeChallenges()
|
||||
{
|
||||
widgDelete(psRequestScreen, CHALLENGE_FORM);
|
||||
widgReleaseScreen(psRequestScreen);
|
||||
delete psRequestScreen;
|
||||
psRequestScreen = NULL;
|
||||
// need to "eat" up the return key so it don't pass back to game.
|
||||
inputLoseFocus();
|
||||
challengesUp = false;
|
||||
|
@ -364,7 +356,7 @@ bool runChallenges(void)
|
|||
// clicked a load entry
|
||||
if (id >= CHALLENGE_ENTRY_START && id <= CHALLENGE_ENTRY_END)
|
||||
{
|
||||
if (((W_BUTTON *)widgGetFromID(psRequestScreen, id))->pText)
|
||||
if (!((W_BUTTON *)widgGetFromID(psRequestScreen, id))->pText.isEmpty())
|
||||
{
|
||||
sstrcpy(sRequestResult, (const char *)((W_BUTTON *)widgGetFromID(psRequestScreen, id))->pUserData);
|
||||
}
|
||||
|
|
|
@ -243,15 +243,6 @@ bool addConsoleMessage(const char *Text, CONSOLE_TEXT_JUSTIFICATION jusType, SDW
|
|||
/* Is the string too long? */
|
||||
textLength = strlen(messageText);
|
||||
|
||||
// FIXME: We split the text correctly in the display routine, however, then the console has no idea it was split,
|
||||
// so that is why you sometimes see text that is below the console line limit that was set via setConsoleLineInfo()
|
||||
// As in the display routines, we should check to see if iV_GetTextWidth(lines.c_str()) > mainConsole.width, but that
|
||||
// isn't working the way it should, so right now, we just throw a warning (only in debug mode) that the text it too long.
|
||||
if (textLength > 72)
|
||||
{
|
||||
debug(LOG_NEVER, "This line is too long, and will be split in the display routines! Line is:[%s]", lines.c_str());
|
||||
}
|
||||
|
||||
ASSERT( textLength < MAX_CONSOLE_STRING_LENGTH, "Attempt to add a message to the console that exceeds MAX_CONSOLE_STRING_LENGTH" );
|
||||
|
||||
/* Are we using a defualt justification? */
|
||||
|
|
743
src/design.cpp
743
src/design.cpp
File diff suppressed because it is too large
Load Diff
|
@ -27,8 +27,6 @@
|
|||
/* Design screen ID's */
|
||||
#define IDDES_FORM 5000 // The base form for the design screen
|
||||
#define IDDES_STATSFORM 5001 // The design screen stats form
|
||||
#define IDDES_TEMPLFORM 5002 // The tabbed form of design templates
|
||||
#define IDDES_COMPFORM 5003 // The tabbed form of components
|
||||
#define IDDES_SYSTEMFORM 5006 // The clickable form for the weapon/ecm/sensor
|
||||
#define IDDES_BODYFORM 5007 // The clickable form for the body
|
||||
#define IDDES_PROPFORM 5008 // The clickable form for the propulsion
|
||||
|
@ -47,8 +45,6 @@
|
|||
#define IDDES_PARTFORM 5027 // Part buttons form
|
||||
#define IDDES_WEAPONS_A 5028 // The weapon TURRET_A button for the Component form (right)
|
||||
#define IDDES_WEAPONS_B 5029 // The weapon TURRET_B button for the Component form (right)
|
||||
#define IDDES_TABSCRL_LEFT 5030 // left scroll button
|
||||
#define IDDES_TABSCRL_RIGHT 5031 // right scroll button
|
||||
|
||||
#define IDDES_STOREBUTTON 5905 // Stored template button
|
||||
|
||||
|
|
|
@ -125,8 +125,8 @@ static void calcAverageTerrainHeight(iView *player);
|
|||
bool doWeDrawProximitys(void);
|
||||
static PIELIGHT getBlueprintColour(STRUCT_STATES state);
|
||||
|
||||
static void NetworkDisplayPlainForm(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours);
|
||||
static void NetworkDisplayImage(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours);
|
||||
static void NetworkDisplayPlainForm(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset);
|
||||
static void NetworkDisplayImage(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset);
|
||||
void NotifyUserOfError(char *msg);
|
||||
extern bool writeGameInfo(const char *pFileName); // Used to help debug issues when we have fatal errors & crash handler testing.
|
||||
/******************** Variables ********************/
|
||||
|
@ -492,15 +492,12 @@ static void showDroidPaths(void)
|
|||
}
|
||||
}
|
||||
/// Renders the Network Issue form
|
||||
static void NetworkDisplayPlainForm(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours)
|
||||
static void NetworkDisplayPlainForm(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
|
||||
{
|
||||
W_TABFORM *Form = (W_TABFORM*)psWidget;
|
||||
UDWORD x0,y0,x1,y1;
|
||||
|
||||
x0 = xOffset+Form->x;
|
||||
y0 = yOffset+Form->y;
|
||||
x1 = x0 + Form->width;
|
||||
y1 = y0 + Form->height;
|
||||
int x0 = xOffset + psWidget->x();
|
||||
int y0 = yOffset + psWidget->y();
|
||||
int x1 = x0 + psWidget->width();
|
||||
int y1 = y0 + psWidget->height();
|
||||
|
||||
// Don't draw anything, a rectangle behind the icon just looks strange, if you notice it.
|
||||
//RenderWindowFrame(FRAME_NORMAL, x0, y0, x1 - x0, y1 - y0);
|
||||
|
@ -511,10 +508,10 @@ static void NetworkDisplayPlainForm(WIDGET *psWidget, UDWORD xOffset, UDWORD yOf
|
|||
}
|
||||
|
||||
/// Displays an image for the Network Issue button
|
||||
static void NetworkDisplayImage(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours)
|
||||
static void NetworkDisplayImage(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
|
||||
{
|
||||
UDWORD x = xOffset+psWidget->x;
|
||||
UDWORD y = yOffset+psWidget->y;
|
||||
int x = xOffset + psWidget->x();
|
||||
int y = yOffset + psWidget->y();
|
||||
UWORD ImageID;
|
||||
CONNECTION_STATUS status = (CONNECTION_STATUS)UNPACKDWORD_TRI_A(psWidget->UserData);
|
||||
|
||||
|
|
191
src/frontend.cpp
191
src/frontend.cpp
|
@ -79,10 +79,6 @@ struct CAMPAIGN_FILE
|
|||
// ////////////////////////////////////////////////////////////////////////////
|
||||
// Global variables
|
||||
|
||||
// Widget code and non-constant strings do not get along
|
||||
static char resolution[WIDG_MAXSTR];
|
||||
static char textureSize[WIDG_MAXSTR];
|
||||
|
||||
tMode titleMode; // the global case
|
||||
tMode lastTitleMode; // Since skirmish and multiplayer setup use the same functions, we use this to go back to the corresponding menu.
|
||||
|
||||
|
@ -917,17 +913,24 @@ bool runAudioOptionsMenu(void)
|
|||
static bool startVideoOptionsMenu(void)
|
||||
{
|
||||
// Generate the resolution string
|
||||
snprintf(resolution, WIDG_MAXSTR, "%d x %d",
|
||||
war_GetWidth(), war_GetHeight());
|
||||
char resolution[43];
|
||||
char textureSize[20];
|
||||
ssprintf(resolution, "%d x %d", war_GetWidth(), war_GetHeight());
|
||||
// Generate texture size string
|
||||
snprintf(textureSize, WIDG_MAXSTR, "%d", getTextureSize());
|
||||
ssprintf(textureSize, "%d", getTextureSize());
|
||||
|
||||
addBackdrop();
|
||||
addTopForm();
|
||||
addBottomForm();
|
||||
|
||||
// Add a note about changes taking effect on restart for certain options
|
||||
addTextHint(FRONTEND_TAKESEFFECT, FRONTEND_POS1X + 48, FRONTEND_POS1Y + 24, _("* Takes effect on game restart"));
|
||||
WIDGET *parent = widgGetFromID(psWScreen, FRONTEND_BOTFORM);
|
||||
|
||||
W_LABEL *label = new W_LABEL(parent);
|
||||
label->setGeometry(FRONTEND_POS1X + 48, FRONTEND_POS1Y, FRONTEND_BUTWIDTH - FRONTEND_POS1X - 48, FRONTEND_BUTHEIGHT);
|
||||
label->setFontColour(WZCOL_TEXT_BRIGHT);
|
||||
label->setString(_("* Takes effect on game restart"));
|
||||
label->setTextAlignment(WLAB_ALIGNBOTTOMLEFT);
|
||||
|
||||
// Fullscreen/windowed
|
||||
addTextButton(FRONTEND_WINDOWMODE, FRONTEND_POS2X-35, FRONTEND_POS2Y, _("Graphics Mode*"), 0);
|
||||
|
@ -1092,7 +1095,8 @@ bool runVideoOptionsMenu(void)
|
|||
war_SetHeight(modes[current].height());
|
||||
|
||||
// Generate the textual representation of the new width and height
|
||||
snprintf(resolution, WIDG_MAXSTR, "%d x %d", modes[current].width(), modes[current].height());
|
||||
char resolution[43];
|
||||
ssprintf(resolution, "%d x %d", modes[current].width(), modes[current].height());
|
||||
|
||||
// Update the widget
|
||||
widgSetString(psWScreen, FRONTEND_RESOLUTION_R, resolution);
|
||||
|
@ -1128,7 +1132,8 @@ bool runVideoOptionsMenu(void)
|
|||
setTextureSize(newTexSize);
|
||||
|
||||
// Generate the string representation of the new size
|
||||
snprintf(textureSize, WIDG_MAXSTR, "%d", newTexSize);
|
||||
char textureSize[20];
|
||||
ssprintf(textureSize, "%d", newTexSize);
|
||||
|
||||
// Update the widget
|
||||
widgSetString(psWScreen, FRONTEND_TEXTURESZ_R, textureSize);
|
||||
|
@ -1406,7 +1411,7 @@ bool runGameOptionsMenu(void)
|
|||
widgSetString(psWScreen, FRONTEND_LANGUAGE_R, getLanguageName());
|
||||
/* Hack to reset current menu text, which looks fancy. */
|
||||
widgSetString(psWScreen, FRONTEND_SIDETEXT, _("GAME OPTIONS"));
|
||||
widgSetTipText(widgGetFromID(psWScreen, FRONTEND_QUIT), P_("menu", "Return"));
|
||||
widgGetFromID(psWScreen, FRONTEND_QUIT)->setTip(P_("menu", "Return"));
|
||||
widgSetString(psWScreen, FRONTEND_LANGUAGE, _("Language"));
|
||||
widgSetString(psWScreen, FRONTEND_COLOUR, _("Unit Colour:"));
|
||||
widgSetString(psWScreen, FRONTEND_COLOUR_CAM, _("Campaign"));
|
||||
|
@ -1541,7 +1546,7 @@ bool runGameOptionsMenu(void)
|
|||
// drawing functions
|
||||
|
||||
// show a background piccy (currently used for version and mods labels)
|
||||
static void displayTitleBitmap(WZ_DECL_UNUSED WIDGET *psWidget, WZ_DECL_UNUSED UDWORD xOffset, WZ_DECL_UNUSED UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours)
|
||||
static void displayTitleBitmap(WZ_DECL_UNUSED WIDGET *psWidget, WZ_DECL_UNUSED UDWORD xOffset, WZ_DECL_UNUSED UDWORD yOffset)
|
||||
{
|
||||
char modListText[MAX_STR_LENGTH] = "";
|
||||
|
||||
|
@ -1567,72 +1572,41 @@ static void displayTitleBitmap(WZ_DECL_UNUSED WIDGET *psWidget, WZ_DECL_UNUSED U
|
|||
|
||||
// ////////////////////////////////////////////////////////////////////////////
|
||||
// show warzone logo
|
||||
static void displayLogo(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours)
|
||||
static void displayLogo(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
|
||||
{
|
||||
iV_DrawImageScaled(FrontImages, IMAGE_FE_LOGO, xOffset + psWidget->x, yOffset + psWidget->y, psWidget->width, psWidget->height);
|
||||
iV_DrawImageScaled(FrontImages, IMAGE_FE_LOGO, xOffset + psWidget->x(), yOffset + psWidget->y(), psWidget->width(), psWidget->height());
|
||||
}
|
||||
|
||||
|
||||
// ////////////////////////////////////////////////////////////////////////////
|
||||
// show, well have a guess..
|
||||
static void displayBigSlider(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours)
|
||||
static void displayBigSlider(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
|
||||
{
|
||||
W_SLIDER *Slider = (W_SLIDER*)psWidget;
|
||||
UDWORD x = xOffset+psWidget->x;
|
||||
UDWORD y = yOffset+psWidget->y;
|
||||
SWORD sx;
|
||||
int x = xOffset + psWidget->x();
|
||||
int y = yOffset + psWidget->y();
|
||||
|
||||
iV_DrawImage(IntImages,IMAGE_SLIDER_BIG,x+STAT_SLD_OX,y+STAT_SLD_OY); // draw bdrop
|
||||
|
||||
sx = (SWORD)((Slider->width-3 - Slider->barSize) * Slider->pos / Slider->numStops); // determine pos.
|
||||
int sx = (Slider->width() - 3 - Slider->barSize) * Slider->pos / Slider->numStops; // determine pos.
|
||||
iV_DrawImage(IntImages,IMAGE_SLIDER_BIGBUT,x+3+sx,y+3); //draw amount
|
||||
}
|
||||
|
||||
static void displayAISlider(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours)
|
||||
static void displayAISlider(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
|
||||
{
|
||||
W_SLIDER *Slider = (W_SLIDER*)psWidget;
|
||||
UDWORD x = xOffset+psWidget->x;
|
||||
UDWORD y = yOffset+psWidget->y;
|
||||
SWORD sx;
|
||||
int x = xOffset + psWidget->x();
|
||||
int y = yOffset + psWidget->y();
|
||||
|
||||
iV_DrawImage(IntImages,IMAGE_SLIDER_AI,x+STAT_SLD_OX,y+STAT_SLD_OY); // draw bdrop
|
||||
|
||||
sx = (SWORD)((Slider->width-3 - Slider->barSize) * Slider->pos / Slider->numStops); // determine pos.
|
||||
int sx = (Slider->width() - 3 - Slider->barSize) * Slider->pos / Slider->numStops; // determine pos.
|
||||
iV_DrawImage(IntImages,IMAGE_SLIDER_BIGBUT,x+3+sx,y+3); //draw amount
|
||||
}
|
||||
|
||||
|
||||
// ////////////////////////////////////////////////////////////////////////////
|
||||
// show text.
|
||||
static void displayText(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours)
|
||||
{
|
||||
SDWORD fx,fy, fw;
|
||||
W_LABEL *psLab;
|
||||
|
||||
psLab = (W_LABEL *)psWidget;
|
||||
iV_SetFont(psLab->FontID);
|
||||
|
||||
fw = iV_GetTextWidth(psLab->aText);
|
||||
fy = yOffset + psWidget->y;
|
||||
|
||||
if (psWidget->style & WLAB_ALIGNCENTRE) //check for centering, calculate offset.
|
||||
{
|
||||
fx = xOffset + psWidget->x + ((psWidget->width - fw) / 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
fx = xOffset + psWidget->x;
|
||||
}
|
||||
|
||||
iV_SetTextColour(WZCOL_TEXT_BRIGHT);
|
||||
iV_DrawText( psLab->aText, fx, fy);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// ////////////////////////////////////////////////////////////////////////////
|
||||
// show text written on its side.
|
||||
static void displayTextAt270(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours)
|
||||
static void displayTextAt270(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
|
||||
{
|
||||
SDWORD fx,fy;
|
||||
W_LABEL *psLab;
|
||||
|
@ -1641,18 +1615,18 @@ static void displayTextAt270(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, W
|
|||
|
||||
iV_SetFont(font_large);
|
||||
|
||||
fx = xOffset + psWidget->x;
|
||||
fy = yOffset + psWidget->y + iV_GetTextWidth(psLab->aText) ;
|
||||
fx = xOffset + psWidget->x();
|
||||
fy = yOffset + psWidget->y() + iV_GetTextWidth(psLab->aText.toUtf8().constData());
|
||||
|
||||
iV_SetTextColour(WZCOL_GREY);
|
||||
iV_DrawTextRotated(psLab->aText, fx+2, fy+2, 270.f);
|
||||
iV_DrawTextRotated(psLab->aText.toUtf8().constData(), fx+2, fy+2, 270.f);
|
||||
iV_SetTextColour(WZCOL_TEXT_BRIGHT);
|
||||
iV_DrawTextRotated(psLab->aText, fx, fy, 270.f);
|
||||
iV_DrawTextRotated(psLab->aText.toUtf8().constData(), fx, fy, 270.f);
|
||||
}
|
||||
|
||||
// ////////////////////////////////////////////////////////////////////////////
|
||||
// show a text option.
|
||||
void displayTextOption(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours)
|
||||
void displayTextOption(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
|
||||
{
|
||||
SDWORD fx,fy, fw;
|
||||
W_BUTTON *psBut;
|
||||
|
@ -1667,16 +1641,16 @@ void displayTextOption(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL
|
|||
hilight = true;
|
||||
}
|
||||
|
||||
fw = iV_GetTextWidth(psBut->pText);
|
||||
fy = yOffset + psWidget->y + (psWidget->height - iV_GetTextLineSize())/2 - iV_GetTextAboveBase();
|
||||
fw = iV_GetTextWidth(psBut->pText.toUtf8().constData());
|
||||
fy = yOffset + psWidget->y() + (psWidget->height() - iV_GetTextLineSize())/2 - iV_GetTextAboveBase();
|
||||
|
||||
if (psWidget->style & WBUT_TXTCENTRE) //check for centering, calculate offset.
|
||||
{
|
||||
fx = xOffset + psWidget->x + ((psWidget->width - fw) / 2);
|
||||
fx = xOffset + psWidget->x() + ((psWidget->width() - fw) / 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
fx = xOffset + psWidget->x;
|
||||
fx = xOffset + psWidget->x();
|
||||
}
|
||||
|
||||
if(greyOut) // unavailable
|
||||
|
@ -1699,7 +1673,7 @@ void displayTextOption(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL
|
|||
}
|
||||
}
|
||||
|
||||
iV_DrawText( psBut->pText, fx, fy);
|
||||
iV_DrawText(psBut->pText.toUtf8().constData(), fx, fy);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -1727,36 +1701,26 @@ void addBackdrop(void)
|
|||
// ////////////////////////////////////////////////////////////////////////////
|
||||
void addTopForm(void)
|
||||
{
|
||||
W_FORMINIT sFormInit;
|
||||
WIDGET *parent = widgGetFromID(psWScreen, FRONTEND_BACKDROP);
|
||||
|
||||
sFormInit.formID = FRONTEND_BACKDROP;
|
||||
sFormInit.id = FRONTEND_TOPFORM;
|
||||
sFormInit.style = WFORM_PLAIN;
|
||||
|
||||
if(titleMode == MULTIOPTION)
|
||||
IntFormAnimated *topForm = new IntFormAnimated(parent, false);
|
||||
topForm->id = FRONTEND_TOPFORM;
|
||||
if (titleMode == MULTIOPTION)
|
||||
{
|
||||
sFormInit.x = FRONTEND_TOPFORM_WIDEX;
|
||||
sFormInit.y = FRONTEND_TOPFORM_WIDEY;
|
||||
sFormInit.width = FRONTEND_TOPFORM_WIDEW;
|
||||
sFormInit.height= FRONTEND_TOPFORM_WIDEH;
|
||||
topForm->setGeometry(FRONTEND_TOPFORM_WIDEX, FRONTEND_TOPFORM_WIDEY, FRONTEND_TOPFORM_WIDEW, FRONTEND_TOPFORM_WIDEH);
|
||||
}
|
||||
else
|
||||
|
||||
{
|
||||
sFormInit.x = FRONTEND_TOPFORMX;
|
||||
sFormInit.y = FRONTEND_TOPFORMY;
|
||||
sFormInit.width = FRONTEND_TOPFORMW;
|
||||
sFormInit.height= FRONTEND_TOPFORMH;
|
||||
topForm->setGeometry(FRONTEND_TOPFORMX, FRONTEND_TOPFORMY, FRONTEND_TOPFORMW, FRONTEND_TOPFORMH);
|
||||
}
|
||||
sFormInit.pDisplay = intDisplayPlainForm;
|
||||
widgAddForm(psWScreen, &sFormInit);
|
||||
|
||||
W_FORMINIT sFormInit;
|
||||
sFormInit.formID= FRONTEND_TOPFORM;
|
||||
sFormInit.id = FRONTEND_LOGO;
|
||||
int imgW = iV_GetImageWidth(FrontImages, IMAGE_FE_LOGO);
|
||||
int imgH = iV_GetImageHeight(FrontImages, IMAGE_FE_LOGO);
|
||||
int dstW = sFormInit.width;
|
||||
int dstH = sFormInit.height;
|
||||
int dstW = topForm->width();
|
||||
int dstH = topForm->height();
|
||||
if (imgW*dstH < imgH*dstW) // Want to set aspect ratio dstW/dstH = imgW/imgH.
|
||||
{
|
||||
dstW = imgW * dstH/imgH; // Too wide.
|
||||
|
@ -1765,8 +1729,8 @@ void addTopForm(void)
|
|||
{
|
||||
dstH = imgH * dstW/imgW; // Too high.
|
||||
}
|
||||
sFormInit.x = (sFormInit.width - dstW)/2;
|
||||
sFormInit.y = (sFormInit.height - dstH)/2;
|
||||
sFormInit.x = (topForm->width() - dstW)/2;
|
||||
sFormInit.y = (topForm->height() - dstH)/2;
|
||||
sFormInit.width = dstW;
|
||||
sFormInit.height = dstH;
|
||||
sFormInit.pDisplay= displayLogo;
|
||||
|
@ -1776,59 +1740,24 @@ void addTopForm(void)
|
|||
// ////////////////////////////////////////////////////////////////////////////
|
||||
void addBottomForm(void)
|
||||
{
|
||||
W_FORMINIT sFormInit;
|
||||
WIDGET *parent = widgGetFromID(psWScreen, FRONTEND_BACKDROP);
|
||||
|
||||
sFormInit.formID = FRONTEND_BACKDROP;
|
||||
sFormInit.id = FRONTEND_BOTFORM;
|
||||
sFormInit.style = WFORM_PLAIN;
|
||||
sFormInit.x = FRONTEND_BOTFORMX;
|
||||
sFormInit.y = FRONTEND_BOTFORMY;
|
||||
sFormInit.width = FRONTEND_BOTFORMW;
|
||||
sFormInit.height = FRONTEND_BOTFORMH;
|
||||
|
||||
sFormInit.pDisplay = intOpenPlainForm;
|
||||
sFormInit.disableChildren = true;
|
||||
|
||||
widgAddForm(psWScreen, &sFormInit);
|
||||
}
|
||||
|
||||
// ////////////////////////////////////////////////////////////////////////////
|
||||
void addTextHint(UDWORD id, UDWORD PosX, UDWORD PosY, const char *txt)
|
||||
{
|
||||
W_LABINIT sLabInit;
|
||||
|
||||
sLabInit.formID = FRONTEND_BOTFORM;
|
||||
sLabInit.id = id;
|
||||
sLabInit.x = (short)PosX;
|
||||
sLabInit.y = (short)PosY;
|
||||
|
||||
sLabInit.width = MULTIOP_READY_WIDTH;
|
||||
sLabInit.height = FRONTEND_BUTHEIGHT;
|
||||
sLabInit.pDisplay = displayText;
|
||||
sLabInit.pText = txt;
|
||||
widgAddLabel(psWScreen, &sLabInit);
|
||||
IntFormAnimated *botForm = new IntFormAnimated(parent);
|
||||
botForm->id = FRONTEND_BOTFORM;
|
||||
botForm->setGeometry(FRONTEND_BOTFORMX, FRONTEND_BOTFORMY, FRONTEND_BOTFORMW, FRONTEND_BOTFORMH);
|
||||
}
|
||||
|
||||
// ////////////////////////////////////////////////////////////////////////////
|
||||
void addText(UDWORD id, UDWORD PosX, UDWORD PosY, const char *txt, UDWORD formID)
|
||||
{
|
||||
W_LABINIT sLabInit;
|
||||
WIDGET *parent = widgGetFromID(psWScreen, formID);
|
||||
|
||||
sLabInit.formID = formID;
|
||||
sLabInit.id = id;
|
||||
sLabInit.x = (short)PosX;
|
||||
sLabInit.y = (short)PosY;
|
||||
sLabInit.style = WLAB_ALIGNCENTRE;
|
||||
|
||||
// Align
|
||||
sLabInit.width = MULTIOP_READY_WIDTH;
|
||||
//sButInit.x+=35;
|
||||
|
||||
sLabInit.height = FRONTEND_BUTHEIGHT;
|
||||
sLabInit.pDisplay = displayText;
|
||||
sLabInit.FontID = font_small;
|
||||
sLabInit.pText = txt;
|
||||
widgAddLabel(psWScreen, &sLabInit);
|
||||
W_LABEL *label = new W_LABEL(parent);
|
||||
label->id = id;
|
||||
label->setGeometry(PosX, PosY, MULTIOP_READY_WIDTH, FRONTEND_BUTHEIGHT);
|
||||
label->setTextAlignment(WLAB_ALIGNCENTRE);
|
||||
label->setFont(font_small, WZCOL_TEXT_BRIGHT);
|
||||
label->setString(txt);
|
||||
}
|
||||
|
||||
// ////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -78,13 +78,11 @@ void addBottomForm(void);
|
|||
void addBackdrop(void);
|
||||
void addTextButton(UDWORD id, UDWORD PosX, UDWORD PosY, const char *txt, unsigned int style);
|
||||
void addSmallTextButton(UDWORD id, UDWORD PosX, UDWORD PosY, const char *txt, unsigned int style);
|
||||
void addTextHint(UDWORD id, UDWORD PosX, UDWORD PosY, const char *txt);
|
||||
void addText(UDWORD id, UDWORD PosX, UDWORD PosY, const char *txt, UDWORD formID);
|
||||
void addSideText(UDWORD id, UDWORD PosX, UDWORD PosY, const char *txt);
|
||||
void addFESlider(UDWORD id, UDWORD parent, UDWORD x, UDWORD y, UDWORD stops, UDWORD pos);
|
||||
void addFEAISlider(UDWORD id, UDWORD parent, UDWORD x, UDWORD y, UDWORD stops, UDWORD pos);
|
||||
|
||||
void displayTextOption(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
void displayTextOption(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset);
|
||||
|
||||
bool CancelPressed(void);
|
||||
|
||||
|
@ -236,7 +234,6 @@ enum
|
|||
FRONTEND_RESOLUTION_R,
|
||||
FRONTEND_TEXTURESZ,
|
||||
FRONTEND_TEXTURESZ_R,
|
||||
FRONTEND_TAKESEFFECT,
|
||||
FRONTEND_VSYNC,
|
||||
FRONTEND_VSYNC_R,
|
||||
FRONTEND_FSAA,
|
||||
|
|
1081
src/hci.cpp
1081
src/hci.cpp
File diff suppressed because it is too large
Load Diff
21
src/hci.h
21
src/hci.h
|
@ -86,8 +86,6 @@
|
|||
#define IDSTAT_TABFORM 14004 // The tab form with the stats buttons
|
||||
#define IDSTAT_START 14100 // The first stats ID
|
||||
#define IDSTAT_END 14999 // The last stats ID enough for 899 things
|
||||
#define IDSTAT_TABSCRL_LEFT 15000 // Our left Tab scroll button
|
||||
#define IDSTAT_TABSCRL_RIGHT 15002 // Our right Tab scroll button
|
||||
#define IDSTAT_TIMEBARSTART 4300
|
||||
#define IDSTAT_TIMEBAREND 4399
|
||||
#define IDSTAT_SLIDER 4400
|
||||
|
@ -140,14 +138,6 @@
|
|||
#define POW_Y (OBJ_BACKY + OBJ_BACKHEIGHT + 6)
|
||||
#define POW_BARWIDTH 308
|
||||
|
||||
//tab details
|
||||
#define OBJ_TABWIDTH 26
|
||||
#define OBJ_TABHEIGHT 11
|
||||
#define OBJ_TABOFFSET 2
|
||||
//tab scroll buttons details
|
||||
#define TABSCRL_HEIGHT 10
|
||||
#define TABSCRL_WIDTH 7
|
||||
|
||||
/* close button data */
|
||||
#define CLOSE_WIDTH 15
|
||||
#define CLOSE_HEIGHT 15
|
||||
|
@ -255,13 +245,6 @@ extern std::list<DROID_TEMPLATE> localTemplates; ///< Unsychnronised list,
|
|||
/* pointer to hold the imd to use for a new template in the design screen */
|
||||
extern iIMDShape *pNewDesignIMD;
|
||||
|
||||
extern bool ClosingMessageView;
|
||||
extern bool ClosingIntelMap;
|
||||
extern bool ClosingTrans;
|
||||
extern bool ClosingTransCont;
|
||||
extern bool ClosingTransDroids;
|
||||
extern bool ClosingOrder;
|
||||
|
||||
/* Initialise the in game interface */
|
||||
extern bool intInitialise(void);
|
||||
|
||||
|
@ -323,8 +306,6 @@ extern bool intBuildMode(void);
|
|||
// add the construction interface if a constructor droid is selected
|
||||
void intCommanderSelected(DROID *psDroid);
|
||||
|
||||
extern UWORD numForms(UDWORD total, UDWORD perForm);
|
||||
|
||||
//sets up the Intelligence Screen as far as the interface is concerned
|
||||
extern void addIntelScreen(void);
|
||||
|
||||
|
@ -393,8 +374,6 @@ extern BASE_OBJECT *getCurrentSelected(void);
|
|||
//initialise all the previous obj - particularly useful for when go Off world!
|
||||
extern void intResetPreviousObj(void);
|
||||
|
||||
extern void HandleClosingWindows(void);
|
||||
|
||||
extern bool intIsRefreshing(void);
|
||||
|
||||
extern void intDemolishCancel(void);
|
||||
|
|
119
src/ingameop.cpp
119
src/ingameop.cpp
|
@ -52,8 +52,7 @@
|
|||
#include "main.h"
|
||||
#include "warzoneconfig.h"
|
||||
|
||||
//status bools.(for hci.h)
|
||||
bool ClosingInGameOp = false;
|
||||
|
||||
bool InGameOpUp = false;
|
||||
bool isInGamePopupUp = false;
|
||||
// ////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -95,32 +94,21 @@ static bool addQuitOptions(void)
|
|||
widgDelete(psWScreen, INTINGAMEPOPUP); // get rid of the old stuff.
|
||||
}
|
||||
|
||||
W_FORMINIT sFormInit;
|
||||
// add form
|
||||
sFormInit.formID = 0;
|
||||
sFormInit.id = INTINGAMEOP;
|
||||
sFormInit.style = WFORM_PLAIN;
|
||||
sFormInit.width = INTINGAMEOP3_W;
|
||||
sFormInit.height = INTINGAMEOP3_H;
|
||||
sFormInit.x = (SWORD)INTINGAMEOP3_X;
|
||||
sFormInit.y = (SWORD)INTINGAMEOP3_Y;
|
||||
sFormInit.pDisplay = intOpenPlainForm;
|
||||
sFormInit.disableChildren= true;
|
||||
WIDGET *parent = psWScreen->psForm;
|
||||
|
||||
widgAddForm(psWScreen, &sFormInit);
|
||||
// add form
|
||||
IntFormAnimated *inGameOp = new IntFormAnimated(parent);
|
||||
inGameOp->id = INTINGAMEOP;
|
||||
inGameOp->setGeometry(INTINGAMEOP3_W, INTINGAMEOP3_H, INTINGAMEOP3_X, INTINGAMEOP3_Y);
|
||||
|
||||
addIGTextButton(INTINGAMEOP_RESUME, INTINGAMEOP_1_X, INTINGAMEOP_1_Y, INTINGAMEOP_OP_W, _("Resume Game"), OPALIGN);
|
||||
addIGTextButton(INTINGAMEOP_QUIT_CONFIRM, INTINGAMEOP_1_X, INTINGAMEOP_2_Y, INTINGAMEOP_OP_W, _("Quit"), OPALIGN);
|
||||
|
||||
if (NetPlay.isHost && bMultiPlayer && NetPlay.bComms) // only show for real MP games
|
||||
{
|
||||
sFormInit.id = INTINGAMEPOPUP;
|
||||
sFormInit.width = 600;
|
||||
sFormInit.height = 26;
|
||||
sFormInit.x = (SWORD)(20+D_W); // center it
|
||||
sFormInit.y = (SWORD) 130;
|
||||
|
||||
widgAddForm(psWScreen, &sFormInit);
|
||||
IntFormAnimated *inGamePopup = new IntFormAnimated(parent);
|
||||
inGamePopup->id = INTINGAMEOP;
|
||||
inGamePopup->setGeometry(600, 26, 20 + D_W, 130);
|
||||
|
||||
W_BUTINIT sButInit;
|
||||
|
||||
|
@ -148,21 +136,12 @@ static bool addSlideOptions(void)
|
|||
widgDelete(psWScreen, INTINGAMEOP); // get rid of the old stuff.
|
||||
}
|
||||
|
||||
W_FORMINIT sFormInit;
|
||||
WIDGET *parent = psWScreen->psForm;
|
||||
|
||||
// add form
|
||||
sFormInit.formID = 0;
|
||||
sFormInit.id = INTINGAMEOP;
|
||||
sFormInit.style = WFORM_PLAIN;
|
||||
sFormInit.x = (SWORD)INTINGAMEOP2_X;
|
||||
sFormInit.y = (SWORD)INTINGAMEOP2_Y;
|
||||
sFormInit.width = INTINGAMEOP2_W;
|
||||
sFormInit.height = INTINGAMEOP2_H;
|
||||
|
||||
sFormInit.pDisplay = intOpenPlainForm;
|
||||
sFormInit.disableChildren= true;
|
||||
|
||||
widgAddForm(psWScreen, &sFormInit);
|
||||
IntFormAnimated *ingameOp = new IntFormAnimated(parent);
|
||||
ingameOp->id = INTINGAMEOP;
|
||||
ingameOp->setGeometry(INTINGAMEOP2_X, INTINGAMEOP2_Y, INTINGAMEOP2_W, INTINGAMEOP2_H);
|
||||
|
||||
// fx vol
|
||||
addIGTextButton(INTINGAMEOP_FXVOL, INTINGAMEOP_2_X, INTINGAMEOP_1_Y, INTINGAMEOP_OP_W, _("Voice Volume"), WBUT_PLAIN);
|
||||
|
@ -227,39 +206,17 @@ static bool _intAddInGameOptions(void)
|
|||
kf_TogglePauseMode();
|
||||
}
|
||||
|
||||
W_FORMINIT sFormInit;
|
||||
sFormInit.width = INTINGAMEOP_W;
|
||||
WIDGET *parent = psWScreen->psForm;
|
||||
|
||||
bool s = (bMultiPlayer && NetPlay.bComms != 0) || bInTutorial;
|
||||
|
||||
// add form
|
||||
sFormInit.formID = 0;
|
||||
sFormInit.id = INTINGAMEOP;
|
||||
sFormInit.style = WFORM_PLAIN;
|
||||
sFormInit.x = (SWORD)INTINGAMEOP_X;
|
||||
sFormInit.y = (SWORD)INTINGAMEOP_Y;
|
||||
sFormInit.height = INTINGAMEOP_H;
|
||||
|
||||
if ((!bMultiPlayer || (NetPlay.bComms == 0)) && !bInTutorial)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
sFormInit.height = INTINGAMEOP_HS;
|
||||
}
|
||||
|
||||
sFormInit.pDisplay = intOpenPlainForm;
|
||||
sFormInit.disableChildren= true;
|
||||
|
||||
widgAddForm(psWScreen, &sFormInit);
|
||||
IntFormAnimated *ingameOp = new IntFormAnimated(parent);
|
||||
ingameOp->id = INTINGAMEOP;
|
||||
ingameOp->setGeometry(INTINGAMEOP_X, INTINGAMEOP_Y, INTINGAMEOP_W, s? INTINGAMEOP_HS : INTINGAMEOP_H);
|
||||
|
||||
// add 'quit' text
|
||||
if ((!bMultiPlayer || (NetPlay.bComms == 0)) && !bInTutorial)
|
||||
{
|
||||
addIGTextButton(INTINGAMEOP_QUIT, INTINGAMEOP_1_X, INTINGAMEOP_5_Y, INTINGAMEOP_OP_W, _("Quit"), OPALIGN);
|
||||
}
|
||||
else
|
||||
{
|
||||
addIGTextButton(INTINGAMEOP_QUIT, INTINGAMEOP_1_X, INTINGAMEOP_3_Y, INTINGAMEOP_OP_W, _("Quit"), OPALIGN);
|
||||
}
|
||||
addIGTextButton(INTINGAMEOP_QUIT, INTINGAMEOP_1_X, s? INTINGAMEOP_3_Y : INTINGAMEOP_5_Y, INTINGAMEOP_OP_W, _("Quit"), OPALIGN);
|
||||
|
||||
// add 'resume'
|
||||
addIGTextButton(INTINGAMEOP_RESUME, INTINGAMEOP_1_X, INTINGAMEOP_1_Y, INTINGAMEOP_OP_W, _("Resume Game"), OPALIGN);
|
||||
|
@ -267,7 +224,7 @@ static bool _intAddInGameOptions(void)
|
|||
// add 'options'
|
||||
addIGTextButton(INTINGAMEOP_OPTIONS, INTINGAMEOP_1_X, INTINGAMEOP_2_Y, INTINGAMEOP_OP_W, _("Audio Options"), OPALIGN);
|
||||
|
||||
if ((!bMultiPlayer || (NetPlay.bComms == 0)) && !bInTutorial)
|
||||
if (!s)
|
||||
{
|
||||
if (!bMultiPlayer)
|
||||
{
|
||||
|
@ -319,19 +276,11 @@ void intAddInGamePopup(void)
|
|||
kf_TogglePauseMode(); // Pause the game.
|
||||
}
|
||||
|
||||
W_FORMINIT sFormInit;
|
||||
WIDGET *parent = psWScreen->psForm;
|
||||
|
||||
sFormInit.formID = 0;
|
||||
sFormInit.id = INTINGAMEPOPUP;
|
||||
sFormInit.style = WFORM_PLAIN;
|
||||
sFormInit.width = 600;
|
||||
sFormInit.height = 160;
|
||||
sFormInit.x = (SWORD)(20+D_W);
|
||||
sFormInit.y = (SWORD)((240-(160/2))+D_H);
|
||||
sFormInit.pDisplay = intOpenPlainForm;
|
||||
sFormInit.disableChildren= true;
|
||||
|
||||
widgAddForm(psWScreen, &sFormInit);
|
||||
IntFormAnimated *ingamePopup = new IntFormAnimated(parent);
|
||||
ingamePopup->id = INTINGAMEPOPUP;
|
||||
ingamePopup->setGeometry(600, 160, 20 + D_W, (240 - 160/2) + D_H);
|
||||
|
||||
// add the text "buttons" now
|
||||
W_BUTINIT sButInit;
|
||||
|
@ -407,9 +356,6 @@ void intCloseInGameOptionsNoAnim(bool bResetMissionWidgets)
|
|||
bool intCloseInGameOptions(bool bPutUpLoadSave, bool bResetMissionWidgets)
|
||||
{
|
||||
|
||||
W_TABFORM *Form;
|
||||
WIDGET *widg;
|
||||
|
||||
if (NetPlay.isHost)
|
||||
{
|
||||
widgDelete(psWScreen, INTINGAMEPOPUP);
|
||||
|
@ -417,35 +363,32 @@ bool intCloseInGameOptions(bool bPutUpLoadSave, bool bResetMissionWidgets)
|
|||
|
||||
if(bPutUpLoadSave)
|
||||
{
|
||||
widg = widgGetFromID(psWScreen,INTINGAMEOP);
|
||||
WIDGET *widg = widgGetFromID(psWScreen, INTINGAMEOP);
|
||||
if(widg)
|
||||
{
|
||||
widgDelete(psWScreen,INTINGAMEOP);
|
||||
}
|
||||
|
||||
InGameOpUp = false;
|
||||
ClosingInGameOp = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// close the form.
|
||||
// Start the window close animation.
|
||||
IntFormAnimated *form;
|
||||
if (isInGamePopupUp) // FIXME: we hijack this routine for the popup close.
|
||||
{
|
||||
Form = (W_TABFORM*)widgGetFromID(psWScreen,INTINGAMEPOPUP);
|
||||
form = (IntFormAnimated *)widgGetFromID(psWScreen, INTINGAMEPOPUP);
|
||||
isInGamePopupUp = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Form = (W_TABFORM*)widgGetFromID(psWScreen,INTINGAMEOP);
|
||||
form = (IntFormAnimated *)widgGetFromID(psWScreen, INTINGAMEOP);
|
||||
}
|
||||
|
||||
if(Form)
|
||||
if (form)
|
||||
{
|
||||
Form->display = intClosePlainForm;
|
||||
Form->pUserData = NULL; // Used to signal when the close anim has finished.
|
||||
Form->disableChildren= true;
|
||||
ClosingInGameOp = true; // like orderup/closingorder
|
||||
form->closeAnimateDelete();
|
||||
InGameOpUp = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@ extern void intProcessInGameOptions (UDWORD);
|
|||
extern void intAddInGamePopup(void);
|
||||
|
||||
// status bools.
|
||||
extern bool ClosingInGameOp;
|
||||
extern bool InGameOpUp;
|
||||
extern bool isInGamePopupUp;
|
||||
// ////////////////////////////////////////////////////////////////////////////
|
||||
|
|
1345
src/intdisplay.cpp
1345
src/intdisplay.cpp
File diff suppressed because it is too large
Load Diff
255
src/intdisplay.h
255
src/intdisplay.h
|
@ -25,16 +25,7 @@
|
|||
#include "lib/widget/form.h"
|
||||
#include "intimage.h"
|
||||
#include "droid.h"
|
||||
|
||||
#define NUM_OBJECTSURFACES (100)
|
||||
#define NUM_TOPICSURFACES (50)
|
||||
#define NUM_STATSURFACES (200)
|
||||
#define NUM_SYSTEM0SURFACES (100)
|
||||
#define NUM_OBJECTBUFFERS (NUM_OBJECTSURFACES*4)
|
||||
#define NUM_STATBUFFERS (NUM_STATSURFACES*4)
|
||||
#define NUM_TOPICBUFFERS (NUM_TOPICSURFACES*4)
|
||||
|
||||
#define NUM_SYSTEM0BUFFERS (NUM_SYSTEM0SURFACES*8)
|
||||
#include "template.h"
|
||||
|
||||
|
||||
/* Power levels are divided by this for power bar display. The extra factor has
|
||||
|
@ -45,12 +36,8 @@ power values in the buttons */
|
|||
#define BUTTONOBJ_ROTSPEED 90 // Speed to rotate objects rendered in
|
||||
// buttons ( degrees per second )
|
||||
|
||||
//the two types of button used in the object display (bottom bar)
|
||||
#define TOPBUTTON 0
|
||||
#define BTMBUTTON 1
|
||||
|
||||
|
||||
enum {
|
||||
enum ImdType
|
||||
{
|
||||
IMDTYPE_NONE,
|
||||
IMDTYPE_DROID,
|
||||
IMDTYPE_DROIDTEMPLATE,
|
||||
|
@ -60,72 +47,31 @@ enum {
|
|||
IMDTYPE_STRUCTURESTAT,
|
||||
};
|
||||
|
||||
#define RENDERBUTTON_INUSE(x) ((x)->InUse=true)
|
||||
#define RENDERBUTTON_NOTINUSE(x) ((x)->InUse=false)
|
||||
|
||||
#define RENDERBUTTON_INITIALISED(x) ((x)->Initialised=true)
|
||||
#define RENDERBUTTON_NOTINITIALISED(x) ((x)->Initialised=false)
|
||||
|
||||
#define IsBufferInUse(x) ((x)->InUse)
|
||||
|
||||
struct RENDERED_BUTTON
|
||||
struct ImdObject
|
||||
{
|
||||
bool InUse; // Is it in use.
|
||||
bool Initialised; // Is it initialised.
|
||||
SDWORD ImdRotation; // Rotation if button is an IMD.
|
||||
UDWORD State; // Copy of widget's state so we know if state has changed.
|
||||
void *Data; // Any data we want to attach.
|
||||
void *Data2; // Any data we want to attach.
|
||||
ImdObject() : ptr(nullptr), type(IMDTYPE_NONE) {}
|
||||
static ImdObject Droid(BASE_OBJECT *p) { return ImdObject(p, IMDTYPE_DROID); }
|
||||
static ImdObject DroidTemplate(BASE_STATS *p) { return ImdObject(p, IMDTYPE_DROIDTEMPLATE); }
|
||||
static ImdObject Component(BASE_STATS *p) { return ImdObject(p, IMDTYPE_COMPONENT); }
|
||||
static ImdObject Structure(BASE_OBJECT *p) { return ImdObject(p, IMDTYPE_STRUCTURE); }
|
||||
static ImdObject Research(BASE_STATS *p) { return ImdObject(p, IMDTYPE_RESEARCH); }
|
||||
static ImdObject StructureStat(BASE_STATS *p) { return ImdObject(p, IMDTYPE_STRUCTURESTAT); }
|
||||
|
||||
bool empty() const { return ptr == nullptr; }
|
||||
|
||||
void *ptr;
|
||||
ImdType type;
|
||||
|
||||
private:
|
||||
ImdObject(void *ptr, ImdType type) : ptr(ptr), type(type) {}
|
||||
};
|
||||
|
||||
extern RENDERED_BUTTON TopicBuffers[NUM_TOPICBUFFERS];
|
||||
extern RENDERED_BUTTON ObjectBuffers[NUM_OBJECTBUFFERS];
|
||||
extern RENDERED_BUTTON StatBuffers[NUM_STATBUFFERS];
|
||||
extern RENDERED_BUTTON System0Buffers[NUM_SYSTEM0BUFFERS];
|
||||
|
||||
extern BASE_STATS *CurrentStatsTemplate;
|
||||
|
||||
// Set audio IDs for form opening/closing anims.
|
||||
void SetFormAudioIDs(int OpenID,int CloseID);
|
||||
|
||||
// Initialise interface graphics.
|
||||
void intInitialiseGraphics(void);
|
||||
|
||||
// Get a free RENDERED_BUTTON structure for an object window button.
|
||||
SDWORD GetObjectBuffer(void);
|
||||
|
||||
// Clear ( make unused ) all RENDERED_BUTTON structures for the object window.
|
||||
void ClearObjectBuffers(void);
|
||||
|
||||
// Clear ( make unused ) all RENDERED_BUTTON structures for the topic window.
|
||||
void ClearTopicBuffers(void);
|
||||
|
||||
// Clear ( make unused ) a RENDERED_BUTTON structure.
|
||||
void ClearObjectButtonBuffer(SDWORD BufferID);
|
||||
|
||||
// Clear ( make unused ) a RENDERED_BUTTON structure.
|
||||
void ClearTopicButtonBuffer(SDWORD BufferID);
|
||||
|
||||
void RefreshObjectButtons(void);
|
||||
void RefreshSystem0Buttons(void);
|
||||
void RefreshTopicButtons(void);
|
||||
void RefreshStatsButtons(void);
|
||||
|
||||
|
||||
// Get a free RENDERED_BUTTON structure for a stat window button.
|
||||
SDWORD GetStatBuffer(void);
|
||||
|
||||
// Clear ( make unused ) all RENDERED_BUTTON structures for the stat window.
|
||||
void ClearStatBuffers(void);
|
||||
|
||||
/*these have been set up for the Transporter - the design screen DOESN'T use them*/
|
||||
// Clear ( make unused ) *all* RENDERED_BUTTON structures.
|
||||
void ClearSystem0Buffers(void);
|
||||
// Clear ( make unused ) a RENDERED_BUTTON structure.
|
||||
void ClearSystem0ButtonBuffer(SDWORD BufferID);
|
||||
// Get a free RENDERED_BUTTON structure.
|
||||
SDWORD GetSystem0Buffer(void);
|
||||
|
||||
// callback to update the command droid size label
|
||||
void intUpdateCommandSize(WIDGET *psWidget, W_CONTEXT *psContext);
|
||||
|
||||
|
@ -143,71 +89,111 @@ extern void intAddFactoryInc(WIDGET *psWidget, W_CONTEXT *psContext);
|
|||
//callback to display the production quantity number for a template
|
||||
extern void intAddProdQuantity(WIDGET *psWidget, W_CONTEXT *psContext);
|
||||
|
||||
void intDisplayPowerBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
void intDisplayPowerBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset);
|
||||
|
||||
void intDisplayStatusButton(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
class IntFancyButton : public W_CLICKFORM
|
||||
{
|
||||
public:
|
||||
IntFancyButton(WIDGET *parent);
|
||||
|
||||
void intDisplayObjectButton(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
protected:
|
||||
//the two types of button used in the object display (bottom bar)
|
||||
enum ButtonType {TOPBUTTON = 0, BTMBUTTON = 1};
|
||||
|
||||
void intDisplayStatsButton(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
void doRotation();
|
||||
void displayClear(int xOffset, int yOffset);
|
||||
void displayIMD(Image image, ImdObject imdObject, int xOffset, int yOffset);
|
||||
void displayImage(Image image, int xOffset, int yOffset);
|
||||
void displayBlank(int xOffset, int yOffset);
|
||||
void displayIfHighlight(int xOffset, int yOffset);
|
||||
|
||||
void AdjustTabFormSize(W_TABFORM *Form,UDWORD *x0,UDWORD *y0,UDWORD *x1,UDWORD *y1);
|
||||
int imdRotation; // Rotation if button is an IMD.
|
||||
int imdRotationRate;
|
||||
ButtonType buttonType; // TOPBUTTON is square, BTMBUTTON has a little up arrow.
|
||||
};
|
||||
|
||||
void intDisplayStatsForm(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
class IntObjectButton : public IntFancyButton
|
||||
{
|
||||
public:
|
||||
IntObjectButton(WIDGET *parent);
|
||||
|
||||
void intOpenPlainForm(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
virtual void display(int xOffset, int yOffset);
|
||||
|
||||
void intClosePlainForm(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
void setObject(BASE_OBJECT *object) { psObj = object; }
|
||||
bool clearData() { bool ret = psObj != nullptr; psObj = nullptr; return ret; }
|
||||
|
||||
void intDisplayPlainForm(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
protected:
|
||||
BASE_OBJECT *psObj;
|
||||
};
|
||||
|
||||
void intDisplayImage(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
class IntStatusButton : public IntObjectButton
|
||||
{
|
||||
public:
|
||||
IntStatusButton(WIDGET *parent);
|
||||
|
||||
void intDisplayImageHilight(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
void setObject(BASE_OBJECT *object) { psObj = object; theStats = nullptr; }
|
||||
void setObjectAndStats(BASE_OBJECT *object, BASE_STATS *stats) { psObj = object; theStats = stats; }
|
||||
|
||||
void intDisplayButtonHilight(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
virtual void display(int xOffset, int yOffset);
|
||||
|
||||
void intDisplayButtonFlash(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
protected:
|
||||
BASE_STATS *theStats;
|
||||
};
|
||||
|
||||
void intDisplayButtonPressed(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
class IntStatsButton : public IntFancyButton
|
||||
{
|
||||
public:
|
||||
IntStatsButton(WIDGET *parent);
|
||||
|
||||
void intDisplayReticuleButton(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
virtual void display(int xOffset, int yOffset);
|
||||
|
||||
void intDisplayTab(WIDGET *psWidget,UDWORD TabType, UDWORD Position,
|
||||
UDWORD Number,bool Selected,bool Hilight,UDWORD x,UDWORD y,UDWORD Width,UDWORD Height);
|
||||
void intDisplaySlider(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
void setStats(BASE_STATS *stats) { Stat = stats; }
|
||||
void setStatsAndTip(BASE_STATS *stats) { setStats(stats); setTip(getStatName(Stat)); }
|
||||
void setStatsAndTip(DROID_TEMPLATE *stats) { setStats(stats); setTip(getTemplateName(stats)); }
|
||||
|
||||
void intDisplayNumber(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
protected:
|
||||
BASE_STATS *Stat;
|
||||
};
|
||||
|
||||
/// Form which animates opening/closing.
|
||||
class IntFormAnimated : public W_FORM
|
||||
{
|
||||
public:
|
||||
IntFormAnimated(WIDGET *parent, bool openAnimate = true);
|
||||
|
||||
virtual void display(int xOffset, int yOffset);
|
||||
|
||||
void closeAnimateDelete(); ///< Animates the form closing, and deletes itself when done.
|
||||
|
||||
private:
|
||||
unsigned startTime; ///< Animation start time
|
||||
int currentAction; ///< Opening/open/closing/closed.
|
||||
};
|
||||
|
||||
void intDisplayImage(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset);
|
||||
|
||||
void intDisplayImageHilight(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset);
|
||||
|
||||
void intDisplayButtonHilight(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset);
|
||||
|
||||
void intDisplayButtonFlash(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset);
|
||||
|
||||
void intDisplayButtonPressed(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset);
|
||||
|
||||
void intDisplayReticuleButton(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset);
|
||||
|
||||
void intDisplaySlider(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset);
|
||||
|
||||
void intDisplayNumber(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset);
|
||||
void intAddLoopQuantity(WIDGET *psWidget, W_CONTEXT *psContext);
|
||||
|
||||
void intDisplayEditBox(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
|
||||
void OpenButtonRender(int XPos, int YPos);
|
||||
|
||||
void ClearButton(bool Down,UDWORD Size, UDWORD buttonType);
|
||||
|
||||
void RenderToButton(IMAGEFILE *ImageFile,UWORD ImageID,void *Object,UDWORD Player,RENDERED_BUTTON *Buffer,
|
||||
bool Down,UDWORD IMDType, UDWORD buttonType);
|
||||
|
||||
void CreateIMDButton(IMAGEFILE *ImageFile,UWORD ImageID,void *Object,UDWORD Player,RENDERED_BUTTON *Buffer,
|
||||
bool Down,UDWORD IMDType,UDWORD buttonType);
|
||||
|
||||
void CreateImageButton(IMAGEFILE *ImageFile,UWORD ImageID,RENDERED_BUTTON *Buffer,bool Down, UDWORD buttonType);
|
||||
|
||||
void CreateBlankButton(RENDERED_BUTTON *Buffer,bool Down, UDWORD buttonType);
|
||||
|
||||
void RenderImageToButton(IMAGEFILE *ImageFile,UWORD ImageID,RENDERED_BUTTON *Buffer,bool Down, UDWORD buttonType);
|
||||
void RenderBlankToButton(RENDERED_BUTTON *Buffer,bool Down, UDWORD buttonType);
|
||||
|
||||
|
||||
extern bool DroidIsRepairing(DROID *Droid);
|
||||
void intDisplayEditBox(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset);
|
||||
|
||||
bool DroidIsBuilding(DROID *Droid);
|
||||
STRUCTURE *DroidGetBuildStructure(DROID *Droid);
|
||||
bool DroidGoingToBuild(DROID *Droid);
|
||||
BASE_STATS *DroidGetBuildStats(DROID *Droid);
|
||||
iIMDShape *DroidGetIMD(DROID *Droid);
|
||||
bool DroidIsDemolishing(DROID *Droid);
|
||||
|
||||
bool StructureIsManufacturingPending(STRUCTURE *structure); ///< Returns true iff the structure is either manufacturing or on hold (even if not yet synchronised). (But ignores research.)
|
||||
bool structureIsResearchingPending(STRUCTURE *structure); ///< Returns true iff the structure is either researching or on hold (even if not yet synchronised). (But ignores manufacturing.)
|
||||
|
@ -226,42 +212,45 @@ SDWORD StatIsComponent(BASE_STATS *Stat);
|
|||
bool StatGetComponentIMD(BASE_STATS *Stat, SDWORD compID,iIMDShape **CompIMD,iIMDShape **MountIMD);
|
||||
|
||||
bool StatIsResearch(BASE_STATS *Stat);
|
||||
void StatGetResearchImage(BASE_STATS *psStat, SDWORD *Image, iIMDShape **Shape,
|
||||
BASE_STATS **ppGraphicData, bool drawTechIcon);
|
||||
|
||||
/* Draws a stats bar for the design screen */
|
||||
extern void intDisplayStatsBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset,
|
||||
PIELIGHT *pColours);
|
||||
void intDisplayStatsBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset);
|
||||
/* Draws a Template Power Bar for the Design Screen */
|
||||
void intDisplayDesignPowerBar(WIDGET *psWidget, UDWORD xOffset,
|
||||
UDWORD yOffset, PIELIGHT *pColours);
|
||||
void intDisplayDesignPowerBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset);
|
||||
|
||||
// Widget callback function to play an audio track.
|
||||
extern void WidgetAudioCallback(int AudioID);
|
||||
|
||||
// Widget callback to display a contents button for the Transporter
|
||||
extern void intDisplayTransportButton(WIDGET *psWidget, UDWORD xOffset,
|
||||
UDWORD yOffset, PIELIGHT *pColours);
|
||||
//void intDisplayTransportButton(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset);
|
||||
class IntTransportButton : public IntFancyButton
|
||||
{
|
||||
public:
|
||||
IntTransportButton(WIDGET *parent);
|
||||
|
||||
virtual void display(int xOffset, int yOffset);
|
||||
|
||||
void setObject(DROID *object) { psDroid = object; }
|
||||
|
||||
protected:
|
||||
DROID *psDroid;
|
||||
};
|
||||
|
||||
/*draws blips on radar to represent Proximity Display*/
|
||||
extern void drawRadarBlips(int radarX, int radarY, float pixSizeH, float pixSizeV);
|
||||
|
||||
/*Displays the proximity messages blips over the world*/
|
||||
extern void intDisplayProximityBlips(WIDGET *psWidget, UDWORD xOffset,
|
||||
UDWORD yOffset, PIELIGHT *pColours);
|
||||
void intDisplayProximityBlips(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset);
|
||||
|
||||
extern void intUpdateQuantitySlider(WIDGET *psWidget, W_CONTEXT *psContext);
|
||||
|
||||
extern void intDisplayDPButton(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
void intDisplayDPButton(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset);
|
||||
|
||||
extern void intDisplayTime(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
extern void intDisplayNum(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
void intDisplayResSubGroup(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset);
|
||||
|
||||
extern void intDisplayResSubGroup(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
void intDisplayMissionClock(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset);
|
||||
|
||||
extern void intDisplayMissionClock(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
|
||||
extern void intDisplayAllyIcon(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
void intDisplayAllyBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
void intDisplayAllyIcon(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset);
|
||||
void intDisplayAllyBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset);
|
||||
|
||||
void intSetShadowPower(int quantity);
|
||||
|
||||
|
|
516
src/intelmap.cpp
516
src/intelmap.cpp
|
@ -76,7 +76,6 @@
|
|||
#define IDINTMAP_FLICVIEW 6008 //The Flic View part of MSGVIEW
|
||||
#define IDINTMAP_TEXTVIEW 6009 //The Text area of MSGVIEW
|
||||
#define IDINTMAP_TITLELABEL 6010 //The title text
|
||||
#define IDINTMAP_SEQTEXT 6011 //Sequence subtitle text
|
||||
|
||||
#define IDINTMAP_MSGSTART 6100 //The first button on the intelligence form
|
||||
#define IDINTMAP_MSGEND 6139 //The last button on the intelligence form (40 MAX)
|
||||
|
@ -95,9 +94,7 @@
|
|||
#define INTMAP_LABELHEIGHT 20
|
||||
|
||||
/*tabbed message form screen positions */
|
||||
#define INTMAP_MSGX OBJ_TABX
|
||||
#define INTMAP_MSGY OBJ_TABY
|
||||
#define INTMAP_MSGWIDTH OBJ_WIDTH
|
||||
#define INTMAP_MSGHEIGHT OBJ_HEIGHT
|
||||
|
||||
//define the 3D View sizes and positions that are required - relative to INTMAP_FORM
|
||||
|
@ -164,21 +161,29 @@ static bool playCurrent;
|
|||
/* functions declarations ****************/
|
||||
static bool intAddMessageForm(bool playCurrent);
|
||||
/*Displays the buttons used on the intelligence map */
|
||||
static void intDisplayMessageButton(WIDGET *psWidget, UDWORD xOffset,
|
||||
UDWORD yOffset, PIELIGHT *pColours);
|
||||
class IntMessageButton : public IntFancyButton
|
||||
{
|
||||
public:
|
||||
IntMessageButton(WIDGET *parent);
|
||||
|
||||
virtual void display(int xOffset, int yOffset);
|
||||
|
||||
void setMessage(MESSAGE *msg) { psMsg = msg; }
|
||||
|
||||
protected:
|
||||
MESSAGE *psMsg;
|
||||
};
|
||||
|
||||
/*deal with the actual button press - proxMsg is set to true if a proximity
|
||||
button has been pressed*/
|
||||
static void intIntelButtonPressed(bool proxMsg, UDWORD id);
|
||||
|
||||
static void intDisplayPIEView(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
static void intDisplayFLICView(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
static void intDisplayTEXTView(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
static void intDisplayPIEView(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset);
|
||||
static void intDisplayFLICView(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset);
|
||||
static void intDisplayTEXTView(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset);
|
||||
static void addVideoText(SEQ_DISPLAY *psSeqDisplay, UDWORD sequence);
|
||||
|
||||
static void intDisplaySeqTextView(WIDGET *psWidget,
|
||||
UDWORD xOffset, UDWORD yOffset,
|
||||
PIELIGHT *pColours);
|
||||
static void intDisplaySeqTextView(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset);
|
||||
static bool intDisplaySeqTextViewPage(VIEW_REPLAY *psViewReplay,
|
||||
UDWORD x0, UDWORD y0,
|
||||
UDWORD width, UDWORD height,
|
||||
|
@ -245,35 +250,12 @@ bool intAddIntelMap(void)
|
|||
//set pause states before putting the interface up
|
||||
setIntelligencePauseState();
|
||||
|
||||
W_FORMINIT sFormInit;
|
||||
WIDGET *parent = psWScreen->psForm;
|
||||
|
||||
// Add the main Intelligence Map form
|
||||
|
||||
sFormInit.formID = 0;
|
||||
sFormInit.id = IDINTMAP_FORM;
|
||||
sFormInit.style = WFORM_PLAIN;
|
||||
sFormInit.x = (SWORD)INTMAP_X;
|
||||
sFormInit.y = (SWORD)INTMAP_Y;
|
||||
sFormInit.width = INTMAP_WIDTH;
|
||||
sFormInit.height = INTMAP_HEIGHT;
|
||||
|
||||
// If the window was closed then do open animation.
|
||||
if(Animate)
|
||||
{
|
||||
sFormInit.pDisplay = intOpenPlainForm;
|
||||
sFormInit.disableChildren = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// otherwise just recreate it.
|
||||
sFormInit.pDisplay = intDisplayPlainForm;
|
||||
}
|
||||
|
||||
//sFormInit.pDisplay = intDisplayPlainForm;
|
||||
if (!widgAddForm(psWScreen, &sFormInit))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
IntFormAnimated *intMapForm = new IntFormAnimated(parent, Animate); // Do not animate the opening, if the window was already open.
|
||||
intMapForm->id = IDINTMAP_FORM;
|
||||
intMapForm->setGeometry(INTMAP_X, INTMAP_Y, INTMAP_WIDTH, INTMAP_HEIGHT);
|
||||
|
||||
if (!intAddMessageForm(playCurrent))
|
||||
{
|
||||
|
@ -291,88 +273,22 @@ bool intAddIntelMap(void)
|
|||
/* Add the Message sub form */
|
||||
static bool intAddMessageForm(bool playCurrent)
|
||||
{
|
||||
UDWORD numButtons, i;
|
||||
MESSAGE *psMessage;
|
||||
RESEARCH *psResearch;
|
||||
SDWORD BufferID;
|
||||
WIDGET *msgForm = widgGetFromID(psWScreen, IDINTMAP_FORM);
|
||||
|
||||
/* Add the Message form */
|
||||
W_FORMINIT sFormInit;
|
||||
sFormInit.formID = IDINTMAP_FORM;
|
||||
sFormInit.id = IDINTMAP_MSGFORM;
|
||||
sFormInit.style = WFORM_TABBED;
|
||||
sFormInit.width = INTMAP_MSGWIDTH;
|
||||
sFormInit.height = INTMAP_MSGHEIGHT;
|
||||
sFormInit.x = INTMAP_MSGX;
|
||||
sFormInit.y = INTMAP_MSGY;
|
||||
|
||||
sFormInit.majorPos = WFORM_TABTOP;
|
||||
sFormInit.minorPos = WFORM_TABNONE;
|
||||
sFormInit.majorSize = OBJ_TABWIDTH;
|
||||
sFormInit.majorOffset = OBJ_TABOFFSET;
|
||||
sFormInit.tabVertOffset = (OBJ_TABHEIGHT/2);
|
||||
sFormInit.tabMajorThickness = OBJ_TABHEIGHT;
|
||||
|
||||
numButtons = 0;
|
||||
/*work out the number of buttons */
|
||||
for(psMessage = apsMessages[selectedPlayer]; psMessage; psMessage =
|
||||
psMessage->psNext)
|
||||
{
|
||||
//ignore proximity messages here
|
||||
if (psMessage->type != MSG_PROXIMITY)
|
||||
{
|
||||
numButtons++;
|
||||
}
|
||||
|
||||
// stop adding the buttons once max has been reached
|
||||
if (numButtons > (IDINTMAP_MSGEND - IDINTMAP_MSGSTART))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//set the number of tabs required
|
||||
sFormInit.numMajor = numForms((OBJ_BUTWIDTH + OBJ_GAP) * numButtons,
|
||||
(OBJ_WIDTH - OBJ_GAP)*2);
|
||||
|
||||
sFormInit.pUserData = &StandardTab;
|
||||
sFormInit.pTabDisplay = intDisplayTab;
|
||||
|
||||
if (sFormInit.numMajor > MAX_TAB_STD_SHOWN)
|
||||
{ // we do NOT use smallTab icons here, so be safe and only display max # of
|
||||
// standard sized tab icons.
|
||||
sFormInit.numMajor = MAX_TAB_STD_SHOWN;
|
||||
}
|
||||
//set minor tabs to 1
|
||||
for (i=0; i< sFormInit.numMajor; i++)
|
||||
{
|
||||
sFormInit.aNumMinors[i] = 1;
|
||||
}
|
||||
|
||||
if (!widgAddForm(psWScreen, &sFormInit))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
IntListTabWidget *msgList = new IntListTabWidget(msgForm);
|
||||
msgList->id = IDINTMAP_MSGFORM;
|
||||
msgList->setChildSize(OBJ_BUTWIDTH, OBJ_BUTHEIGHT);
|
||||
msgList->setChildSpacing(OBJ_GAP, OBJ_GAP);
|
||||
int msgListWidth = OBJ_BUTWIDTH*5 + OBJ_GAP*4;
|
||||
msgList->setGeometry((msgForm->width() - msgListWidth)/2, INTMAP_MSGY, msgListWidth, msgForm->height() - INTMAP_MSGY);
|
||||
|
||||
/* Add the message buttons */
|
||||
W_FORMINIT sBFormInit;
|
||||
sBFormInit.formID = IDINTMAP_MSGFORM;
|
||||
sBFormInit.id = IDINTMAP_MSGSTART;
|
||||
sBFormInit.majorID = 0;
|
||||
sBFormInit.minorID = 0;
|
||||
sBFormInit.style = WFORM_CLICKABLE;
|
||||
sBFormInit.x = OBJ_STARTX;
|
||||
sBFormInit.y = OBJ_STATSTARTY;
|
||||
sBFormInit.width = OBJ_BUTWIDTH;
|
||||
sBFormInit.height = OBJ_BUTHEIGHT;
|
||||
|
||||
ClearObjectBuffers();
|
||||
int nextButtonId = IDINTMAP_MSGSTART;
|
||||
|
||||
//add each button
|
||||
messageID = 0;
|
||||
for(psMessage = apsMessages[selectedPlayer]; psMessage; psMessage =
|
||||
psMessage->psNext)
|
||||
for (MESSAGE *psMessage = apsMessages[selectedPlayer]; psMessage != nullptr; psMessage = psMessage->psNext)
|
||||
{
|
||||
/*if (psMessage->type == MSG_TUTORIAL)
|
||||
{
|
||||
|
@ -386,73 +302,52 @@ static bool intAddMessageForm(bool playCurrent)
|
|||
continue;
|
||||
}
|
||||
|
||||
IntMessageButton *button = new IntMessageButton(msgList);
|
||||
button->id = nextButtonId;
|
||||
button->setMessage(psMessage);
|
||||
msgList->addWidgetToLayout(button);
|
||||
|
||||
/* Set the tip and add the button */
|
||||
RESEARCH *psResearch;
|
||||
switch (psMessage->type)
|
||||
{
|
||||
case MSG_RESEARCH:
|
||||
psResearch = getResearchForMsg((VIEWDATA *)psMessage->pViewData);
|
||||
psResearch = getResearchForMsg((VIEWDATA *)psMessage->pViewData);
|
||||
if (psResearch)
|
||||
{
|
||||
sBFormInit.pTip = getStatName(psResearch);
|
||||
button->setTip(getStatName(psResearch));
|
||||
}
|
||||
else
|
||||
{
|
||||
sBFormInit.pTip = _("Research Update");
|
||||
button->setTip(_("Research Update"));
|
||||
}
|
||||
break;
|
||||
case MSG_CAMPAIGN:
|
||||
sBFormInit.pTip = _("Project Goals");
|
||||
button->setTip(_("Project Goals"));
|
||||
break;
|
||||
case MSG_MISSION:
|
||||
sBFormInit.pTip = _("Current Objective");
|
||||
button->setTip(_("Current Objective"));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
BufferID = GetObjectBuffer();
|
||||
ASSERT( BufferID >= 0,"Unable to acquire object buffer." );
|
||||
RENDERBUTTON_INUSE(&ObjectBuffers[BufferID]);
|
||||
ObjectBuffers[BufferID].Data = (void*)psMessage;
|
||||
sBFormInit.pUserData = &ObjectBuffers[BufferID];
|
||||
sBFormInit.pDisplay = intDisplayMessageButton;
|
||||
|
||||
if (!widgAddForm(psWScreen, &sBFormInit))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* if the current message matches psSelected lock the button */
|
||||
if (psMessage == psCurrentMsg)
|
||||
{
|
||||
messageID = sBFormInit.id;
|
||||
widgSetButtonState(psWScreen, messageID, WBUT_LOCK);
|
||||
widgSetTabs(psWScreen, IDINTMAP_MSGFORM, sBFormInit.majorID, 0);
|
||||
messageID = nextButtonId;
|
||||
button->setState(WBUT_LOCK);
|
||||
msgList->setCurrentPage(msgList->pages() - 1);
|
||||
}
|
||||
|
||||
/* Update the init struct for the next button */
|
||||
sBFormInit.id += 1;
|
||||
++nextButtonId;
|
||||
|
||||
// stop adding the buttons when at max
|
||||
if (sBFormInit.id > IDINTMAP_MSGEND)
|
||||
if (nextButtonId > IDINTMAP_MSGEND)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
ASSERT( sBFormInit.id < (IDINTMAP_MSGEND+1),"Too many message buttons" );
|
||||
|
||||
sBFormInit.x += OBJ_BUTWIDTH + OBJ_GAP;
|
||||
if (sBFormInit.x + OBJ_BUTWIDTH + OBJ_GAP > INTMAP_MSGWIDTH)
|
||||
{
|
||||
sBFormInit.x = OBJ_STARTX;
|
||||
sBFormInit.y += OBJ_BUTHEIGHT + OBJ_GAP;
|
||||
}
|
||||
|
||||
if (sBFormInit.y + OBJ_BUTHEIGHT + OBJ_GAP > INTMAP_MSGHEIGHT)
|
||||
{
|
||||
sBFormInit.y = OBJ_STATSTARTY;
|
||||
sBFormInit.majorID += 1;
|
||||
}
|
||||
}
|
||||
//check to play current message instantly
|
||||
if (playCurrent)
|
||||
|
@ -487,39 +382,17 @@ bool intAddMessageView(MESSAGE * psMessage)
|
|||
intCloseMultiMenuNoAnim();
|
||||
}
|
||||
|
||||
/* Add the base form */
|
||||
W_FORMINIT sFormInit;
|
||||
sFormInit.formID = 0;
|
||||
sFormInit.id = IDINTMAP_MSGVIEW;
|
||||
sFormInit.style = WFORM_PLAIN;
|
||||
//size and position depends on the type of message - ONLY RESEARCH now
|
||||
sFormInit.width = INTMAP_RESEARCHWIDTH;
|
||||
sFormInit.height = INTMAP_RESEARCHHEIGHT;
|
||||
sFormInit.x = (SWORD)INTMAP_RESEARCHX;
|
||||
sFormInit.y = (SWORD)INTMAP_RESEARCHY;
|
||||
WIDGET *parent = psWScreen->psForm;
|
||||
|
||||
// If the window was closed then do open animation.
|
||||
if(Animate)
|
||||
{
|
||||
sFormInit.pDisplay = intOpenPlainForm;
|
||||
sFormInit.disableChildren = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// otherwise just display it.
|
||||
sFormInit.pDisplay = intDisplayPlainForm;
|
||||
}
|
||||
|
||||
if (!widgAddForm(psWScreen, &sFormInit))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
IntFormAnimated *intMapMsgView = new IntFormAnimated(parent, Animate); // Do not animate the opening, if the window was already open.
|
||||
intMapMsgView->id = IDINTMAP_MSGVIEW;
|
||||
intMapMsgView->setGeometry(INTMAP_RESEARCHX, INTMAP_RESEARCHY, INTMAP_RESEARCHWIDTH, INTMAP_RESEARCHHEIGHT);
|
||||
|
||||
/* Add the close box */
|
||||
W_BUTINIT sButInit;
|
||||
sButInit.formID = IDINTMAP_MSGVIEW;
|
||||
sButInit.id = IDINTMAP_CLOSE;
|
||||
sButInit.x = (SWORD)(sFormInit.width - OPT_GAP - CLOSE_SIZE);
|
||||
sButInit.x = intMapMsgView->width() - OPT_GAP - CLOSE_SIZE;
|
||||
sButInit.y = OPT_GAP;
|
||||
sButInit.width = CLOSE_SIZE;
|
||||
sButInit.height = CLOSE_SIZE;
|
||||
|
@ -535,69 +408,27 @@ bool intAddMessageView(MESSAGE * psMessage)
|
|||
((VIEWDATA*)psMessage->pViewData)->type == VIEW_RPL)
|
||||
{
|
||||
VIEW_REPLAY *psViewReplay;
|
||||
size_t i, cur_seq, cur_seqpage;
|
||||
|
||||
psViewReplay = (VIEW_REPLAY *)((VIEWDATA *)psMessage->pViewData)->pData;
|
||||
|
||||
/* Add a big tabbed text box for the subtitle text */
|
||||
sFormInit = W_FORMINIT();
|
||||
IntListTabWidget *seqList = new IntListTabWidget(intMapMsgView);
|
||||
seqList->setChildSize(INTMAP_SEQTEXTTABWIDTH, INTMAP_SEQTEXTTABHEIGHT);
|
||||
seqList->setChildSpacing(2, 2);
|
||||
seqList->setGeometry(INTMAP_SEQTEXTX, INTMAP_SEQTEXTY, INTMAP_SEQTEXTWIDTH, INTMAP_SEQTEXTHEIGHT);
|
||||
seqList->setTabPosition(ListTabWidget::Bottom);
|
||||
// Don't think the tabs are actually ever used...
|
||||
|
||||
sFormInit.id = IDINTMAP_SEQTEXT;
|
||||
sFormInit.formID = IDINTMAP_MSGVIEW;
|
||||
sFormInit.style = WFORM_TABBED;
|
||||
sFormInit.x = INTMAP_SEQTEXTX;
|
||||
sFormInit.y = INTMAP_SEQTEXTY;
|
||||
sFormInit.width = INTMAP_SEQTEXTWIDTH;
|
||||
sFormInit.height = INTMAP_SEQTEXTHEIGHT;
|
||||
|
||||
sFormInit.majorPos = WFORM_TABBOTTOM;
|
||||
sFormInit.minorPos = WFORM_TABNONE;
|
||||
sFormInit.majorSize = OBJ_TABWIDTH;
|
||||
sFormInit.majorOffset = OBJ_TABOFFSET;
|
||||
sFormInit.tabVertOffset = (OBJ_TABHEIGHT/2);
|
||||
sFormInit.tabMajorThickness = OBJ_TABHEIGHT;
|
||||
|
||||
sFormInit.numMajor = 0;
|
||||
|
||||
cur_seq = cur_seqpage = 0;
|
||||
size_t cur_seq = 0, cur_seqpage = 0;
|
||||
int nextPageId = IDINTMAP_SEQTEXTSTART;
|
||||
do {
|
||||
sFormInit.aNumMinors[sFormInit.numMajor] = 1;
|
||||
sFormInit.numMajor++;
|
||||
}
|
||||
while (!intDisplaySeqTextViewPage(psViewReplay, 0, 0,
|
||||
sFormInit.width, sFormInit.height,
|
||||
false, &cur_seq, &cur_seqpage));
|
||||
|
||||
sFormInit.pUserData = &StandardTab;
|
||||
sFormInit.pTabDisplay = intDisplayTab;
|
||||
|
||||
if (!widgAddForm(psWScreen, &sFormInit))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
W_FORMINIT sTabForm;
|
||||
sTabForm.formID = IDINTMAP_SEQTEXT;
|
||||
sTabForm.id = IDINTMAP_SEQTEXTSTART;
|
||||
sTabForm.majorID = 0;
|
||||
sTabForm.minorID = 0;
|
||||
sTabForm.style = WFORM_PLAIN;
|
||||
sTabForm.x = INTMAP_SEQTEXTTABX;
|
||||
sTabForm.y = INTMAP_SEQTEXTTABY;
|
||||
sTabForm.width = INTMAP_SEQTEXTTABWIDTH;
|
||||
sTabForm.height = INTMAP_SEQTEXTTABHEIGHT;
|
||||
sTabForm.pDisplay = intDisplaySeqTextView;
|
||||
sTabForm.pUserData = psViewReplay;
|
||||
|
||||
for (i = 0; i < sFormInit.numMajor; i++)
|
||||
{
|
||||
sTabForm.id = IDINTMAP_SEQTEXTSTART + i;
|
||||
sTabForm.majorID = i;
|
||||
if (!widgAddForm(psWScreen, &sTabForm))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
W_FORM *page = new W_FORM(seqList);
|
||||
page->id = nextPageId++;
|
||||
page->displayFunction = intDisplaySeqTextView;
|
||||
page->pUserData = psViewReplay;
|
||||
seqList->addWidgetToLayout(page);
|
||||
}
|
||||
while (!intDisplaySeqTextViewPage(psViewReplay, 0, 0, INTMAP_SEQTEXTTABWIDTH, INTMAP_SEQTEXTHEIGHT, false, &cur_seq, &cur_seqpage));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -628,8 +459,7 @@ bool intAddMessageView(MESSAGE * psMessage)
|
|||
}
|
||||
|
||||
/*Add the PIE box*/
|
||||
|
||||
sFormInit = W_FORMINIT();
|
||||
W_FORMINIT sFormInit;
|
||||
sFormInit.formID = IDINTMAP_MSGVIEW;
|
||||
sFormInit.id = IDINITMAP_PIEVIEW;
|
||||
sFormInit.style = WFORM_PLAIN;
|
||||
|
@ -761,37 +591,20 @@ static bool intDisplaySeqTextViewPage(VIEW_REPLAY *psViewReplay,
|
|||
/**
|
||||
* Draw the text window for the intelligence display
|
||||
*/
|
||||
static void intDisplaySeqTextView(WIDGET *psWidget,
|
||||
UDWORD xOffset, UDWORD yOffset,
|
||||
WZ_DECL_UNUSED PIELIGHT *pColours)
|
||||
static void intDisplaySeqTextView(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
|
||||
{
|
||||
W_TABFORM *Form = (W_TABFORM*)psWidget;
|
||||
VIEW_REPLAY *psViewReplay = (VIEW_REPLAY*)Form->pUserData;
|
||||
VIEW_REPLAY *psViewReplay = (VIEW_REPLAY*)psWidget->pUserData;
|
||||
size_t cur_seq, cur_seqpage;
|
||||
UDWORD x0, y0, page;
|
||||
|
||||
x0 = xOffset + Form->x;
|
||||
y0 = yOffset + Form->y;
|
||||
int x0 = xOffset + psWidget->x();
|
||||
int y0 = yOffset + psWidget->y();
|
||||
|
||||
RenderWindowFrame(FRAME_NORMAL, x0, y0, Form->width, Form->height);
|
||||
RenderWindowFrame(FRAME_NORMAL, x0, y0, psWidget->width(), psWidget->height());
|
||||
|
||||
/* work out where we're up to in the text */
|
||||
cur_seq = cur_seqpage = 0;
|
||||
if(Form->style & WFORM_TABBED)
|
||||
{
|
||||
// Gerard 2007-04-07: dead code?
|
||||
ASSERT(!"the form is tabbed", "intDisplaySeqTextView: the form is tabbed");
|
||||
for (page = 0; page < Form->majorT; page++)
|
||||
{
|
||||
intDisplaySeqTextViewPage(psViewReplay, x0, y0,
|
||||
Form->width, Form->height,
|
||||
false, &cur_seq, &cur_seqpage);
|
||||
}
|
||||
}
|
||||
|
||||
intDisplaySeqTextViewPage(psViewReplay, x0, y0,
|
||||
Form->width-40, Form->height,
|
||||
true, &cur_seq, &cur_seqpage);
|
||||
intDisplaySeqTextViewPage(psViewReplay, x0, y0, psWidget->width() - 40, psWidget->height(), true, &cur_seq, &cur_seqpage);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1033,25 +846,19 @@ static void intCleanUpIntelMap(void)
|
|||
/* Remove the Intelligence Map widgets from the screen */
|
||||
void intRemoveIntelMap(void)
|
||||
{
|
||||
WIDGET *Widg;
|
||||
W_TABFORM *Form;
|
||||
|
||||
//remove 3dView if still there
|
||||
Widg = widgGetFromID(psWScreen,IDINTMAP_MSGVIEW);
|
||||
WIDGET *Widg = widgGetFromID(psWScreen, IDINTMAP_MSGVIEW);
|
||||
if(Widg)
|
||||
{
|
||||
intRemoveMessageView(false);
|
||||
}
|
||||
|
||||
// Start the window close animation.
|
||||
Form = (W_TABFORM*)widgGetFromID(psWScreen,IDINTMAP_FORM);
|
||||
if(Form)
|
||||
IntFormAnimated *form = (IntFormAnimated *)widgGetFromID(psWScreen, IDINTMAP_FORM);
|
||||
if (form)
|
||||
{
|
||||
Form->display = intClosePlainForm;
|
||||
Form->disableChildren = true;
|
||||
Form->pUserData = NULL; // Used to signal when the close anim has finished.
|
||||
form->closeAnimateDelete();
|
||||
}
|
||||
ClosingIntelMap = true;
|
||||
//remove the text label
|
||||
widgDelete(psWScreen, IDINTMAP_PAUSELABEL);
|
||||
|
||||
|
@ -1090,62 +897,46 @@ void intRemoveIntelMapNoAnim(void)
|
|||
/* Remove the Message View from the Intelligence screen */
|
||||
void intRemoveMessageView(bool animated)
|
||||
{
|
||||
W_TABFORM *Form;
|
||||
VIEW_RESEARCH *psViewResearch;
|
||||
|
||||
//remove 3dView if still there
|
||||
Form = (W_TABFORM*)widgGetFromID(psWScreen,IDINTMAP_MSGVIEW);
|
||||
if(Form)
|
||||
IntFormAnimated *form = (IntFormAnimated *)widgGetFromID(psWScreen, IDINTMAP_MSGVIEW);
|
||||
if (form == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//stop the video
|
||||
psViewResearch = (VIEW_RESEARCH *)Form->pUserData;
|
||||
seq_RenderVideoToBuffer(psViewResearch->sequenceName, SEQUENCE_KILL);
|
||||
//stop the video
|
||||
VIEW_RESEARCH *psViewResearch = (VIEW_RESEARCH *)form->pUserData;
|
||||
seq_RenderVideoToBuffer(psViewResearch->sequenceName, SEQUENCE_KILL);
|
||||
|
||||
if (animated)
|
||||
{
|
||||
|
||||
widgDelete(psWScreen, IDINTMAP_CLOSE);
|
||||
|
||||
|
||||
// Start the window close animation.
|
||||
Form->display = intClosePlainForm;
|
||||
Form->disableChildren = true;
|
||||
Form->pUserData = NULL; // Used to signal when the close anim has finished.
|
||||
ClosingMessageView = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//remove without the animating close window
|
||||
widgDelete(psWScreen, IDINTMAP_MSGVIEW);
|
||||
|
||||
}
|
||||
if (animated)
|
||||
{
|
||||
// Start the window close animation.
|
||||
form->closeAnimateDelete();
|
||||
}
|
||||
else
|
||||
{
|
||||
//remove without the animating close window
|
||||
delete form;
|
||||
}
|
||||
}
|
||||
|
||||
IntMessageButton::IntMessageButton(WIDGET *parent)
|
||||
: IntFancyButton(parent)
|
||||
, psMsg(nullptr)
|
||||
{}
|
||||
|
||||
/*Displays the buttons used on the intelligence map */
|
||||
void intDisplayMessageButton(WIDGET *psWidget, UDWORD xOffset,
|
||||
UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours)
|
||||
void IntMessageButton::display(int xOffset, int yOffset)
|
||||
{
|
||||
W_CLICKFORM *psButton = (W_CLICKFORM*)psWidget;
|
||||
RENDERED_BUTTON *psBuffer = (RENDERED_BUTTON*)psButton->pUserData;
|
||||
MESSAGE *psMsg;
|
||||
bool Hilight = false;
|
||||
UDWORD Down = 0, IMDType = 0, compID;
|
||||
SDWORD image = -1;
|
||||
RESEARCH *pResearch = NULL;
|
||||
BASE_STATS *psResGraphic = NULL;
|
||||
bool MovieButton = false;
|
||||
|
||||
OpenButtonRender(xOffset + psButton->x, yOffset + psButton->y);
|
||||
doRotation();
|
||||
|
||||
Down = psButton->state & (WBUTS_DOWN | WBUTS_CLICKLOCK);
|
||||
Hilight = psButton->state & WBUTS_HILITE;
|
||||
ImdObject object;
|
||||
|
||||
Image image;
|
||||
|
||||
// Get the object associated with this widget.
|
||||
psMsg = (MESSAGE *)psBuffer->Data;
|
||||
ASSERT_OR_RETURN( , psMsg != NULL, "psBuffer->Data empty. Why?" );
|
||||
//shouldn't have any proximity messages here...
|
||||
if (psMsg->type == MSG_PROXIMITY)
|
||||
{
|
||||
|
@ -1164,39 +955,35 @@ void intDisplayMessageButton(WIDGET *psWidget, UDWORD xOffset,
|
|||
if (StatIsStructure(pResearch->psStat))
|
||||
{
|
||||
//this defines how the button is drawn
|
||||
IMDType = IMDTYPE_STRUCTURESTAT;
|
||||
psResGraphic = pResearch->psStat;
|
||||
object = ImdObject::StructureStat(pResearch->psStat);
|
||||
}
|
||||
else
|
||||
{
|
||||
compID = StatIsComponent(pResearch->psStat);
|
||||
int compID = StatIsComponent(pResearch->psStat);
|
||||
if (compID != COMP_UNKNOWN)
|
||||
{
|
||||
//this defines how the button is drawn
|
||||
IMDType = IMDTYPE_COMPONENT;
|
||||
psResGraphic = pResearch->psStat;
|
||||
object = ImdObject::Component(pResearch->psStat);
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSERT( false, "intDisplayMessageButton: invalid stat" );
|
||||
IMDType = IMDTYPE_RESEARCH;
|
||||
psResGraphic = (BASE_STATS *)pResearch;
|
||||
object = ImdObject::Research(pResearch);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//no Stat for this research topic so use the research topic to define what is drawn
|
||||
psResGraphic = (BASE_STATS *)pResearch;
|
||||
IMDType = IMDTYPE_RESEARCH;
|
||||
object = ImdObject::Research(pResearch);
|
||||
}
|
||||
break;
|
||||
case MSG_CAMPAIGN:
|
||||
image = IMAGE_INTEL_CAMPAIGN;
|
||||
image = Image(IntImages, IMAGE_INTEL_CAMPAIGN);
|
||||
MovieButton = true;
|
||||
break;
|
||||
case MSG_MISSION:
|
||||
image = IMAGE_INTEL_MISSION;
|
||||
image = Image(IntImages, IMAGE_INTEL_MISSION);
|
||||
MovieButton = true;
|
||||
break;
|
||||
default:
|
||||
|
@ -1209,52 +996,27 @@ void intDisplayMessageButton(WIDGET *psWidget, UDWORD xOffset,
|
|||
{
|
||||
if (pResearch->iconID != NO_RESEARCH_ICON)
|
||||
{
|
||||
image = pResearch->iconID;
|
||||
image = Image(IntImages, pResearch->iconID);
|
||||
}
|
||||
|
||||
//do we have the same icon for the top right hand corner?
|
||||
if (image > 0)
|
||||
{
|
||||
RenderToButton(IntImages, (UWORD)image, psResGraphic, selectedPlayer, psBuffer,Down, IMDType, TOPBUTTON);
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderToButton(NULL,0,pResearch,selectedPlayer,psBuffer,Down,IMDType,TOPBUTTON); //ajl, changed from 0 to selectedPlayer
|
||||
}
|
||||
displayIMD(image, object, xOffset, yOffset);
|
||||
}
|
||||
else
|
||||
//draw buttons for mission and general messages
|
||||
{
|
||||
if (image > 0)
|
||||
{
|
||||
|
||||
if(MovieButton) {
|
||||
// draw the button with the relevant image, don't add Down to the image ID if it's
|
||||
// a movie button.
|
||||
RenderImageToButton(IntImages,(UWORD)(image),psBuffer,Down,TOPBUTTON);
|
||||
} else {
|
||||
//draw the button with the relevant image
|
||||
RenderImageToButton(IntImages,(UWORD)(image+Down),psBuffer,Down,TOPBUTTON);
|
||||
}
|
||||
|
||||
}
|
||||
// Draw the button with the relevant image, don't add isDown() to the image ID if it's a movie button.
|
||||
displayImage(MovieButton? image : Image(image.images, image.id + isDown()), xOffset, yOffset);
|
||||
}
|
||||
|
||||
if (Hilight)
|
||||
{
|
||||
|
||||
iV_DrawImage(IntImages,IMAGE_BUT_HILITE,xOffset+psButton->x,
|
||||
yOffset+psButton->y);
|
||||
}
|
||||
displayIfHighlight(xOffset, yOffset);
|
||||
}
|
||||
|
||||
|
||||
/* displays the PIE view for the current message */
|
||||
void intDisplayPIEView(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours)
|
||||
void intDisplayPIEView(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
|
||||
{
|
||||
W_TABFORM *Form = (W_TABFORM*)psWidget;
|
||||
MESSAGE *psMessage = (MESSAGE *)Form->pUserData;
|
||||
UDWORD x0,y0,x1,y1;
|
||||
MESSAGE *psMessage = (MESSAGE *)psWidget->pUserData;
|
||||
SWORD image = -1;
|
||||
RESEARCH *psResearch;
|
||||
|
||||
|
@ -1266,16 +1028,14 @@ void intDisplayPIEView(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL
|
|||
|
||||
if (psMessage->pViewData)
|
||||
{
|
||||
x0 = xOffset+Form->x;
|
||||
y0 = yOffset+Form->y;
|
||||
x1 = x0 + Form->width;
|
||||
y1 = y0 + Form->height;
|
||||
int x0 = xOffset + psWidget->x();
|
||||
int y0 = yOffset + psWidget->y();
|
||||
int x1 = x0 + psWidget->width();
|
||||
int y1 = y0 + psWidget->height();
|
||||
|
||||
//moved from after close render
|
||||
RenderWindowFrame(FRAME_NORMAL, x0 - 1, y0 - 1, x1 - x0 + 2, y1 - y0 + 2);
|
||||
|
||||
OpenButtonRender(xOffset + Form->x, yOffset + Form->y);
|
||||
|
||||
if (((VIEWDATA *)psMessage->pViewData)->type != VIEW_RES)
|
||||
{
|
||||
ASSERT( false, "intDisplayPIEView: Invalid message type" );
|
||||
|
@ -1296,12 +1056,9 @@ void intDisplayPIEView(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL
|
|||
}
|
||||
|
||||
/* displays the FLIC view for the current message */
|
||||
void intDisplayFLICView(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours)
|
||||
void intDisplayFLICView(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
|
||||
{
|
||||
|
||||
W_TABFORM *Form = (W_TABFORM*)psWidget;
|
||||
MESSAGE *psMessage = (MESSAGE *)Form->pUserData;
|
||||
UDWORD x0,y0,x1,y1;
|
||||
MESSAGE *psMessage = (MESSAGE *)psWidget->pUserData;
|
||||
VIEW_RESEARCH *psViewResearch;
|
||||
|
||||
//shouldn't have any proximity messages here...
|
||||
|
@ -1312,12 +1069,10 @@ void intDisplayFLICView(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DEC
|
|||
|
||||
if (psMessage->pViewData)
|
||||
{
|
||||
OpenButtonRender(xOffset + Form->x, yOffset + Form->y);
|
||||
|
||||
x0 = xOffset+Form->x;
|
||||
y0 = yOffset+Form->y;
|
||||
x1 = x0 + Form->width;
|
||||
y1 = y0 + Form->height;
|
||||
int x0 = xOffset + psWidget->x();
|
||||
int y0 = yOffset + psWidget->y();
|
||||
int x1 = x0 + psWidget->width();
|
||||
int y1 = y0 + psWidget->height();
|
||||
|
||||
if (((VIEWDATA *)psMessage->pViewData)->type != VIEW_RES)
|
||||
{
|
||||
|
@ -1339,18 +1094,15 @@ void intDisplayFLICView(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DEC
|
|||
* If this function breaks, please merge it with intDisplaySeqTextViewPage
|
||||
* which presumably does almost the same.
|
||||
*/
|
||||
void intDisplayTEXTView(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours)
|
||||
void intDisplayTEXTView(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
|
||||
{
|
||||
W_TABFORM *Form = (W_TABFORM*)psWidget;
|
||||
MESSAGE *psMessage = (MESSAGE *)Form->pUserData;
|
||||
UDWORD x0, y0, x1, y1, i, linePitch;
|
||||
UDWORD ty;
|
||||
MESSAGE *psMessage = (MESSAGE *)psWidget->pUserData;
|
||||
|
||||
x0 = xOffset+Form->x;
|
||||
y0 = yOffset+Form->y;
|
||||
x1 = x0 + Form->width;
|
||||
y1 = y0 + Form->height;
|
||||
ty = y0;
|
||||
int x0 = xOffset + psWidget->x();
|
||||
int y0 = yOffset + psWidget->y();
|
||||
int x1 = x0 + psWidget->width();
|
||||
int y1 = y0 + psWidget->height();
|
||||
int ty = y0;
|
||||
|
||||
RenderWindowFrame(FRAME_NORMAL, x0, y0, x1 - x0, y1 - y0);
|
||||
|
||||
|
@ -1358,7 +1110,7 @@ void intDisplayTEXTView(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DEC
|
|||
{
|
||||
iV_SetFont(font_regular);
|
||||
/* Get the travel to the next line */
|
||||
linePitch = iV_GetTextLineSize();
|
||||
int linePitch = iV_GetTextLineSize();
|
||||
/* Fix for spacing.... */
|
||||
linePitch+=3;
|
||||
ty+=3;
|
||||
|
@ -1367,10 +1119,10 @@ void intDisplayTEXTView(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DEC
|
|||
|
||||
iV_SetTextColour(WZCOL_TEXT_BRIGHT);
|
||||
//add each message
|
||||
for (i = 0; i < ((VIEWDATA *)psMessage->pViewData)->textMsg.size(); i++)
|
||||
for (unsigned i = 0; i < ((VIEWDATA *)psMessage->pViewData)->textMsg.size(); i++)
|
||||
{
|
||||
//check haven't run out of room first!
|
||||
if (i * linePitch > Form->height)
|
||||
if (i * linePitch > psWidget->height())
|
||||
{
|
||||
ASSERT( false, "intDisplayTEXTView: Run out of room!" );
|
||||
return;
|
||||
|
|
|
@ -144,31 +144,6 @@ IMAGEFRAME FrameRadar = {
|
|||
{FR_IGNORE, 0,0, 0,0 ,0}},
|
||||
};
|
||||
|
||||
// Tab definitions, defines graphics to use for major and minor tabs.
|
||||
TABDEF StandardTab = {
|
||||
IMAGE_TAB1, // Major tab normal.
|
||||
IMAGE_TAB1DOWN, // Major tab clicked.
|
||||
IMAGE_TABHILIGHT, // Major tab hilighted by mouse.
|
||||
IMAGE_TABSELECTED, // Major tab currently selected.
|
||||
|
||||
IMAGE_TAB1, // Minor tab tab Normal.
|
||||
IMAGE_TAB1DOWN, // Minor tab clicked.
|
||||
IMAGE_TABHILIGHT, // Minor tab hilighted by mouse.
|
||||
IMAGE_TABSELECTED, // Minor tab currently selected.
|
||||
};
|
||||
|
||||
TABDEF SmallTab = {
|
||||
IMAGE_TAB1_SM, // Major tab normal.
|
||||
IMAGE_TAB1DOWN_SM, // Major tab clicked.
|
||||
IMAGE_TABHILIGHT_SM, // Major tab hilighted by mouse.
|
||||
IMAGE_TAB1SELECTED_SM, // Major tab currently selected.
|
||||
|
||||
IMAGE_TAB1_SM, // Minor tab tab Normal.
|
||||
IMAGE_TAB1DOWN_SM, // Minor tab clicked.
|
||||
IMAGE_TABHILIGHT_SM, // Minor tab hilighted by mouse.
|
||||
IMAGE_TAB1SELECTED_SM, // Minor tab currently selected.
|
||||
};
|
||||
|
||||
// Read bitmaps used by the interface.
|
||||
//
|
||||
bool imageInitBitmaps(void)
|
||||
|
@ -277,3 +252,12 @@ void RenderWindowFrame(FRAMETYPE frame, UDWORD x, UDWORD y, UDWORD Width, UDWORD
|
|||
Height - HTopRight - HBottomRight);
|
||||
}
|
||||
}
|
||||
|
||||
IntListTabWidget::IntListTabWidget(WIDGET *parent)
|
||||
: ListTabWidget(parent)
|
||||
{
|
||||
tabWidget()->setHeight(15);
|
||||
tabWidget()->addStyle(TabSelectionStyle(Image(IntImages, IMAGE_TAB1), Image(IntImages, IMAGE_TAB1DOWN), Image(IntImages, IMAGE_TABHILIGHT), Image(), Image(), Image(), Image(), Image(), Image(), 2));
|
||||
tabWidget()->addStyle(TabSelectionStyle(Image(IntImages, IMAGE_TAB1_SM), Image(IntImages, IMAGE_TAB1DOWN_SM), Image(IntImages, IMAGE_TABHILIGHT_SM), Image(), Image(), Image(), Image(), Image(), Image(), 2));
|
||||
tabWidget()->addStyle(TabSelectionStyle(Image(IntImages, IMAGE_TAB1_SM), Image(IntImages, IMAGE_TAB1DOWN_SM), Image(IntImages, IMAGE_TABHILIGHT_SM), Image(IntImages, IMAGE_LFTTAB), Image(IntImages, IMAGE_LFTTABD), Image(IntImages, IMAGE_LFTTABD), Image(IntImages, IMAGE_RGTTAB), Image(IntImages, IMAGE_RGTTABD), Image(IntImages, IMAGE_RGTTABD), 2));
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#define __INCLUDED_INTIMAGE__
|
||||
|
||||
#include "intfac.h" // Interface image id's.
|
||||
#include "lib/widget/listwidget.h"
|
||||
|
||||
#define FILLRED 16
|
||||
#define FILLGREEN 16
|
||||
|
@ -39,19 +40,16 @@ struct TABDEF
|
|||
SWORD MajorDown; //< Index of image to use for tab pressed.
|
||||
SWORD MajorHilight; //< Index of image to use for tab hilighted by mouse.
|
||||
SWORD MajorSelected; //< Index of image to use for tab selected (same as pressed).
|
||||
};
|
||||
|
||||
SWORD MinorUp; //< As above but for minor tabs.
|
||||
SWORD MinorDown;
|
||||
SWORD MinorHilight;
|
||||
SWORD MinorSelected;
|
||||
class IntListTabWidget : public ListTabWidget
|
||||
{
|
||||
public:
|
||||
IntListTabWidget(WIDGET *parent);
|
||||
};
|
||||
|
||||
extern IMAGEFILE *IntImages; //< All the 2d graphics for the user interface.
|
||||
|
||||
// A few useful defined tabs.
|
||||
extern TABDEF StandardTab;
|
||||
extern TABDEF SmallTab;
|
||||
|
||||
bool imageInitBitmaps(void);
|
||||
|
||||
/** Draws a transparent window. */
|
||||
|
|
|
@ -441,7 +441,6 @@ bool intAddOrder(BASE_OBJECT *psObj)
|
|||
bool Animate = true;
|
||||
SECONDARY_STATE State;
|
||||
UWORD OrdIndex;
|
||||
W_FORM *Form;
|
||||
UWORD Height, NumDisplayedOrders;
|
||||
UWORD NumButs;
|
||||
UWORD NumJustifyButs, NumCombineButs, NumCombineBefore;
|
||||
|
@ -535,30 +534,12 @@ bool intAddOrder(BASE_OBJECT *psObj)
|
|||
}
|
||||
}
|
||||
|
||||
widgEndScreen(psWScreen);
|
||||
WIDGET *parent = psWScreen->psForm;
|
||||
|
||||
/* Create the basic form */
|
||||
|
||||
W_FORMINIT sFormInit;
|
||||
sFormInit.formID = 0;
|
||||
sFormInit.id = IDORDER_FORM;
|
||||
sFormInit.style = WFORM_PLAIN;
|
||||
sFormInit.x = ORDER_X;
|
||||
sFormInit.y = ORDER_Y;
|
||||
sFormInit.width = ORDER_WIDTH;
|
||||
sFormInit.height = ORDER_HEIGHT;
|
||||
// If the window was closed then do open animation.
|
||||
if(Animate) {
|
||||
sFormInit.pDisplay = intOpenPlainForm;
|
||||
sFormInit.disableChildren = true;
|
||||
} else {
|
||||
// otherwise just recreate it.
|
||||
sFormInit.pDisplay = intDisplayPlainForm;
|
||||
}
|
||||
if (!widgAddForm(psWScreen, &sFormInit))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
IntFormAnimated *orderForm = new IntFormAnimated(parent, Animate); // Do not animate the opening, if the window was already open.
|
||||
orderForm->id = IDORDER_FORM;
|
||||
orderForm->setGeometry(ORDER_X, ORDER_Y, ORDER_WIDTH, ORDER_HEIGHT);
|
||||
|
||||
// Add the close button.
|
||||
W_BUTINIT sButInit;
|
||||
|
@ -623,15 +604,15 @@ bool intAddOrder(BASE_OBJECT *psObj)
|
|||
break;
|
||||
|
||||
case ORD_JUSTIFY_RIGHT:
|
||||
sButInit.x = (SWORD)(sFormInit.width - ORDER_BUTX -
|
||||
( ((NumJustifyButs * GetImageWidth(IntImages,OrderButtons[OrdIndex].ButImageID[0])) +
|
||||
((NumJustifyButs-1) * ORDER_BUTGAP ) ) ));
|
||||
sButInit.x = orderForm->width() - ORDER_BUTX -
|
||||
(NumJustifyButs * GetImageWidth(IntImages, OrderButtons[OrdIndex].ButImageID[0]) +
|
||||
(NumJustifyButs - 1) * ORDER_BUTGAP);
|
||||
break;
|
||||
|
||||
case ORD_JUSTIFY_CENTER:
|
||||
sButInit.x = ((SWORD)((sFormInit.width ) -
|
||||
( ((NumJustifyButs * GetImageWidth(IntImages,OrderButtons[OrdIndex].ButImageID[0])) +
|
||||
((NumJustifyButs-1) * ORDER_BUTGAP ) ))))/2;
|
||||
sButInit.x = (orderForm->width() -
|
||||
(NumJustifyButs * GetImageWidth(IntImages, OrderButtons[OrdIndex].ButImageID[0]) +
|
||||
(NumJustifyButs - 1) * ORDER_BUTGAP))/2;
|
||||
break;
|
||||
|
||||
case ORD_JUSTIFY_COMBINE:
|
||||
|
@ -669,9 +650,9 @@ bool intAddOrder(BASE_OBJECT *psObj)
|
|||
else
|
||||
{
|
||||
// center the buttons
|
||||
sButInit.x = (SWORD)((sFormInit.width / 2) -
|
||||
( ((NumCombineButs * GetImageWidth(IntImages,OrderButtons[OrdIndex].ButImageID[0])) +
|
||||
((NumCombineButs-1) * ORDER_BUTGAP ) ) / 2 ));
|
||||
sButInit.x = orderForm->width()/2 -
|
||||
(NumCombineButs * GetImageWidth(IntImages, OrderButtons[OrdIndex].ButImageID[0]) +
|
||||
(NumCombineButs - 1) * ORDER_BUTGAP)/2;
|
||||
sButInit.x = (SWORD)(sButInit.x +
|
||||
(GetImageWidth(IntImages,OrderButtons[OrdIndex].ButImageID[0]) + ORDER_BUTGAP ) * NumCombineBefore);
|
||||
}
|
||||
|
@ -775,9 +756,8 @@ bool intAddOrder(BASE_OBJECT *psObj)
|
|||
}
|
||||
|
||||
// Now we know how many orders there are we can resize the form accordingly.
|
||||
Form = (W_FORM*)widgGetFromID(psWScreen,IDORDER_FORM);
|
||||
Form->height = (UWORD)(Height + CLOSE_HEIGHT + ORDER_BUTGAP);
|
||||
Form->y = (SWORD)(ORDER_BOTTOMY-Form->height);
|
||||
int newHeight = Height + CLOSE_HEIGHT + ORDER_BUTGAP;
|
||||
orderForm->setGeometry(orderForm->x(), ORDER_BOTTOMY - newHeight, orderForm->width(), newHeight);
|
||||
|
||||
OrderUp = true;
|
||||
|
||||
|
@ -1096,18 +1076,13 @@ bool intRefreshOrder(void)
|
|||
//
|
||||
void intRemoveOrder(void)
|
||||
{
|
||||
W_TABFORM *Form;
|
||||
|
||||
widgDelete(psWScreen, IDORDER_CLOSE);
|
||||
|
||||
// Start the window close animation.
|
||||
Form = (W_TABFORM*)widgGetFromID(psWScreen,IDORDER_FORM);
|
||||
if (Form)
|
||||
IntFormAnimated *form = (IntFormAnimated *)widgGetFromID(psWScreen, IDORDER_FORM);
|
||||
if (form != nullptr)
|
||||
{
|
||||
Form->display = intClosePlainForm;
|
||||
Form->pUserData = NULL; // Used to signal when the close anim has finished.
|
||||
Form->disableChildren = true;
|
||||
ClosingOrder = true;
|
||||
form->closeAnimateDelete();
|
||||
OrderUp = false;
|
||||
SelectedDroids.clear();
|
||||
psSelectedFactory = NULL;
|
||||
|
|
|
@ -69,6 +69,7 @@
|
|||
#include "lib/widget/form.h"
|
||||
#include "lib/widget/label.h"
|
||||
#include "lib/widget/button.h"
|
||||
#include "lib/widget/listwidget.h"
|
||||
#include "order.h"
|
||||
#include "lib/ivis_opengl/piestate.h"
|
||||
// FIXME Direct iVis implementation include!
|
||||
|
@ -101,8 +102,6 @@
|
|||
Alex McLean, Pumpkin Studios, EIDOS Interactive.
|
||||
*/
|
||||
|
||||
//#define DEBUG_SCROLLTABS //enable to see tab scroll button info for buttons
|
||||
|
||||
#define MAP_ZOOM_RATE (1000)
|
||||
#define MAP_PITCH_RATE (SPIN_SCALING/SECS_PER_SPIN)
|
||||
|
||||
|
@ -2846,93 +2845,38 @@ void kf_NoAssert()
|
|||
// rotuine to decrement the tab-scroll 'buttons'
|
||||
void kf_BuildPrevPage()
|
||||
{
|
||||
W_TABFORM *psTForm;
|
||||
int temp;
|
||||
int tabPos;
|
||||
|
||||
ASSERT_OR_RETURN( , psWScreen != NULL, " Invalid screen pointer!");
|
||||
psTForm = (W_TABFORM *)widgGetFromID(psWScreen, IDSTAT_TABFORM); //get our form
|
||||
ListTabWidget *psTForm = (ListTabWidget *)widgGetFromID(psWScreen, IDSTAT_TABFORM);
|
||||
if (psTForm == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (psTForm->TabMultiplier < 1)
|
||||
{
|
||||
psTForm->TabMultiplier = 1; // 1-based
|
||||
}
|
||||
|
||||
temp = psTForm->majorT - 1;
|
||||
if (temp < 0)
|
||||
if (!psTForm->setCurrentPage(psTForm->currentPage() - 1))
|
||||
{
|
||||
audio_PlayTrack(ID_SOUND_BUILD_FAIL);
|
||||
return;
|
||||
}
|
||||
|
||||
psTForm->majorT = temp;
|
||||
tabPos = ((psTForm->majorT) % TAB_SEVEN); // The tabs position on the page
|
||||
if ((tabPos == (TAB_SEVEN - 1)) && (psTForm->TabMultiplier > 1))
|
||||
{
|
||||
psTForm->TabMultiplier -= 1;
|
||||
}
|
||||
audio_PlayTrack(ID_SOUND_BUTTON_CLICK_5);
|
||||
|
||||
#ifdef DEBUG_SCROLLTABS
|
||||
console("Tabs: %d - MaxTabs: %d - MajorT: %d - numMajor: %d - TabMultiplier: %d",numTabs, maxTabs, psTForm->majorT, psTForm->numMajor, psTForm->TabMultiplier);
|
||||
#endif
|
||||
}
|
||||
|
||||
// rotuine to advance the tab-scroll 'buttons'
|
||||
void kf_BuildNextPage()
|
||||
{
|
||||
W_TABFORM *psTForm;
|
||||
int numTabs;
|
||||
int maxTabs;
|
||||
int tabPos;
|
||||
|
||||
ASSERT_OR_RETURN( , psWScreen != NULL, " Invalid screen pointer!");
|
||||
|
||||
psTForm = (W_TABFORM *)widgGetFromID(psWScreen, IDSTAT_TABFORM);
|
||||
ListTabWidget *psTForm = (ListTabWidget *)widgGetFromID(psWScreen, IDSTAT_TABFORM);
|
||||
if (psTForm == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (psTForm->TabMultiplier < 1)
|
||||
{
|
||||
psTForm->TabMultiplier = 1; // 1-based
|
||||
audio_PlayTrack(ID_SOUND_BUILD_FAIL);
|
||||
}
|
||||
numTabs = numForms(psTForm->numStats,psTForm->numButtons);
|
||||
maxTabs = ((numTabs /TAB_SEVEN)); // (Total tabs needed / 7(max tabs that fit))+1
|
||||
|
||||
if (psTForm->majorT < numTabs - 1)
|
||||
{
|
||||
// Increase tab if we are not on the last one
|
||||
psTForm->majorT += 1; // set tab # to next "page"
|
||||
}
|
||||
else
|
||||
if (!psTForm->setCurrentPage(psTForm->currentPage() + 1))
|
||||
{
|
||||
// went over max
|
||||
audio_PlayTrack(ID_SOUND_BUILD_FAIL);
|
||||
return;
|
||||
}
|
||||
tabPos = ((psTForm->majorT) % TAB_SEVEN); // The tabs position on the page
|
||||
// 7 mod 7 = 0, since we are going forward we can assume it's the next tab
|
||||
if ((tabPos == 0) && (psTForm->TabMultiplier <= maxTabs))
|
||||
{
|
||||
psTForm->TabMultiplier += 1;
|
||||
}
|
||||
|
||||
if (psTForm->majorT >= psTForm->numMajor)
|
||||
{
|
||||
psTForm->majorT = psTForm->numMajor - 1;
|
||||
}
|
||||
audio_PlayTrack( ID_SOUND_BUTTON_CLICK_5 );
|
||||
|
||||
#ifdef DEBUG_SCROLLTABS
|
||||
console("Tabs: %d - MaxTabs: %d - MajorT: %d - numMajor: %d - TabMultiplier: %d",numTabs, maxTabs, psTForm->majorT, psTForm->numMajor, psTForm->TabMultiplier);
|
||||
#endif
|
||||
audio_PlayTrack(ID_SOUND_BUTTON_CLICK_5);
|
||||
}
|
||||
|
||||
|
||||
|
|
172
src/keyedit.cpp
172
src/keyedit.cpp
|
@ -33,6 +33,7 @@
|
|||
#include "lib/ivis_opengl/pieblitfunc.h"
|
||||
#include "lib/sound/audio.h"
|
||||
#include "lib/sound/audio_id.h"
|
||||
#include "lib/widget/button.h"
|
||||
|
||||
#include "frend.h"
|
||||
#include "frontend.h"
|
||||
|
@ -49,7 +50,6 @@
|
|||
// defines
|
||||
|
||||
#define KM_FORM 10200
|
||||
#define KM_FORM_TABS 10201
|
||||
#define KM_RETURN 10202
|
||||
#define KM_DEFAULT 10203
|
||||
|
||||
|
@ -62,10 +62,9 @@
|
|||
#define KM_Y 20
|
||||
#define KM_SX FRONTEND_SIDEX
|
||||
|
||||
#define BUTTONSPERKEYMAPPAGE 20
|
||||
|
||||
#define KM_ENTRYW (FRONTEND_BOTFORMW - 80)
|
||||
#define KM_ENTRYH (( (KM_H-50)/BUTTONSPERKEYMAPPAGE )-3 )
|
||||
#define KM_ENTRYH (16)
|
||||
|
||||
|
||||
// ////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -249,12 +248,12 @@ static bool keyMapToString(char *pStr, KEY_MAPPING *psMapping)
|
|||
|
||||
// ////////////////////////////////////////////////////////////////////////////
|
||||
// display a keymap on the interface.
|
||||
static void displayKeyMap(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours)
|
||||
static void displayKeyMap(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
|
||||
{
|
||||
UDWORD x = xOffset+psWidget->x;
|
||||
UDWORD y = yOffset+psWidget->y;
|
||||
UDWORD w = psWidget->width;
|
||||
UDWORD h = psWidget->height;
|
||||
int x = xOffset + psWidget->x();
|
||||
int y = yOffset + psWidget->y();
|
||||
int w = psWidget->width();
|
||||
int h = psWidget->height();
|
||||
KEY_MAPPING *psMapping = (KEY_MAPPING*)psWidget->pUserData;
|
||||
char sKey[MAX_STR_LENGTH];
|
||||
|
||||
|
@ -276,7 +275,7 @@ static void displayKeyMap(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_D
|
|||
iV_SetFont(font_regular); // font type
|
||||
iV_SetTextColour(WZCOL_FORM_TEXT);
|
||||
|
||||
iV_DrawText(_(psMapping->pName), x + 2, y + (psWidget->height / 2) + 3);
|
||||
iV_DrawText(_(psMapping->pName), x + 2, y + (psWidget->height() / 2) + 3);
|
||||
|
||||
// draw binding
|
||||
keyMapToString(sKey, psMapping);
|
||||
|
@ -286,19 +285,17 @@ static void displayKeyMap(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_D
|
|||
iV_SetTextColour(WZCOL_YELLOW);
|
||||
sstrcat(sKey, " (numpad)");
|
||||
}
|
||||
iV_DrawText(sKey, x + 364, y + (psWidget->height / 2) + 3);
|
||||
iV_DrawText(sKey, x + 364, y + (psWidget->height() / 2) + 3);
|
||||
}
|
||||
|
||||
static bool keyMappingSort(KEY_MAPPING const *a, KEY_MAPPING const *b)
|
||||
{
|
||||
return strcmp(a->pName, b->pName) < 0;
|
||||
}
|
||||
|
||||
// ////////////////////////////////////////////////////////////////////////////
|
||||
bool startKeyMapEditor(bool first)
|
||||
{
|
||||
KEY_MAPPING *psMapping;
|
||||
UDWORD i,mapcount =0;
|
||||
UDWORD bubbleCount;
|
||||
bool bAtEnd,bGotOne;
|
||||
KEY_MAPPING *psPresent = NULL, *psNext;
|
||||
char test[255];
|
||||
|
||||
addBackdrop();
|
||||
addSideText(FRONTEND_SIDETEXT, KM_SX, KM_Y, _("KEY MAPPING"));
|
||||
|
||||
|
@ -306,16 +303,12 @@ bool startKeyMapEditor(bool first)
|
|||
{
|
||||
loadKeyMap(); // get the current mappings.
|
||||
}
|
||||
W_FORMINIT sFormInit;
|
||||
sFormInit.formID = FRONTEND_BACKDROP;
|
||||
sFormInit.id = KM_FORM;
|
||||
sFormInit.style = WFORM_PLAIN;
|
||||
sFormInit.x = KM_X;
|
||||
sFormInit.y = KM_Y;
|
||||
sFormInit.width = KM_W;
|
||||
sFormInit.height = KM_H;
|
||||
sFormInit.pDisplay = intDisplayPlainForm;
|
||||
widgAddForm(psWScreen, &sFormInit);
|
||||
|
||||
WIDGET *parent = widgGetFromID(psWScreen, FRONTEND_BACKDROP);
|
||||
|
||||
IntFormAnimated *kmForm = new IntFormAnimated(parent, false);
|
||||
kmForm->id = KM_FORM;
|
||||
kmForm->setGeometry(KM_X, KM_Y, KM_W, KM_H);
|
||||
|
||||
addMultiBut(psWScreen,KM_FORM,KM_RETURN, // return button.
|
||||
8,5,
|
||||
|
@ -325,121 +318,38 @@ bool startKeyMapEditor(bool first)
|
|||
|
||||
addMultiBut(psWScreen,KM_FORM,KM_DEFAULT,
|
||||
11,45,
|
||||
56,38,
|
||||
iV_GetImageWidth(FrontImages, IMAGE_KEYMAP_DEFAULT), iV_GetImageWidth(FrontImages, IMAGE_KEYMAP_DEFAULT),
|
||||
_("Select Default"),
|
||||
IMAGE_KEYMAP_DEFAULT, IMAGE_KEYMAP_DEFAULT_HI, IMAGE_KEYMAP_DEFAULT_HI); // default.
|
||||
|
||||
/* Better be none that come after this...! */
|
||||
sstrcpy(test, "zzzzzzzzzzzzzzzzzzzzz");
|
||||
psMapping = NULL;
|
||||
|
||||
//count mappings required.
|
||||
for(psMapping = keyMappings; psMapping; psMapping = psMapping->psNext)
|
||||
{
|
||||
if( (psMapping->status!=KEYMAP__DEBUG)&&(psMapping->status!=KEYMAP___HIDE)) // if it's not a debug mapping..
|
||||
{
|
||||
mapcount++;
|
||||
if(strcmp(psMapping->pName,test) < 0)
|
||||
{
|
||||
/* Best one found so far */
|
||||
sstrcpy(test, psMapping->pName);
|
||||
psPresent = psMapping;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add tab form..
|
||||
sFormInit = W_FORMINIT();
|
||||
sFormInit.formID = KM_FORM;
|
||||
sFormInit.id = KM_FORM_TABS;
|
||||
sFormInit.style = WFORM_TABBED;
|
||||
sFormInit.x = 50;
|
||||
sFormInit.y = 10;
|
||||
sFormInit.width = KM_W- 100;
|
||||
sFormInit.height = KM_H- 4;
|
||||
sFormInit.numMajor = numForms(mapcount, BUTTONSPERKEYMAPPAGE);
|
||||
sFormInit.majorPos = WFORM_TABTOP;
|
||||
sFormInit.minorPos = WFORM_TABNONE;
|
||||
sFormInit.majorSize = OBJ_TABWIDTH+3;
|
||||
sFormInit.majorOffset = OBJ_TABOFFSET;
|
||||
sFormInit.tabVertOffset = (OBJ_TABHEIGHT/2);
|
||||
sFormInit.tabMajorThickness = OBJ_TABHEIGHT;
|
||||
sFormInit.pUserData = &StandardTab;
|
||||
sFormInit.pTabDisplay = intDisplayTab;
|
||||
|
||||
// TABFIXME: Special case for tabs, since this one has whole screen to itself. No need to modify(?)
|
||||
for (i=0; i< sFormInit.numMajor; i++)
|
||||
{
|
||||
sFormInit.aNumMinors[i] = 1;
|
||||
}
|
||||
widgAddForm(psWScreen, &sFormInit);
|
||||
IntListTabWidget *kmList = new IntListTabWidget(kmForm);
|
||||
kmList->setChildSize(KM_ENTRYW, KM_ENTRYH);
|
||||
kmList->setChildSpacing(3, 3);
|
||||
kmList->setGeometry(52, 10, KM_ENTRYW, KM_H - 10 - 25);
|
||||
|
||||
//Put the buttons on it
|
||||
W_BUTINIT sButInit;
|
||||
sButInit.formID = KM_FORM_TABS;
|
||||
sButInit.width = KM_ENTRYW;
|
||||
sButInit.height = KM_ENTRYH;
|
||||
sButInit.pDisplay = displayKeyMap;
|
||||
sButInit.x = 2;
|
||||
sButInit.y = 16;
|
||||
sButInit.id = KM_START;
|
||||
|
||||
/* Add our first mapping to the form */
|
||||
sButInit.pUserData= psPresent;
|
||||
widgAddButton(psWScreen, &sButInit);
|
||||
sButInit.id++;
|
||||
sButInit.y += KM_ENTRYH +3;
|
||||
|
||||
/* Now add the others... */
|
||||
bubbleCount = 0;
|
||||
bAtEnd = false;
|
||||
/* Stop when the right number or when aphabetically last - not sure...! */
|
||||
while(bubbleCount<mapcount-1 && !bAtEnd)
|
||||
std::vector<KEY_MAPPING *> mappings;
|
||||
for (KEY_MAPPING *m = keyMappings; m != nullptr; m = m->psNext)
|
||||
{
|
||||
/* Same test as before for upper limit */
|
||||
sstrcpy(test, "zzzzzzzzzzzzzzzzzzzzz");
|
||||
for(psMapping = keyMappings,psNext = NULL,bGotOne = false; psMapping; psMapping = psMapping->psNext)
|
||||
if (m->status != KEYMAP__DEBUG && m->status != KEYMAP___HIDE) // if it's not a debug mapping..
|
||||
{
|
||||
/* Only certain mappings get displayed */
|
||||
if( (psMapping->status!=KEYMAP__DEBUG)&&(psMapping->status!=KEYMAP___HIDE)) // if it's not a debug mapping..
|
||||
{
|
||||
/* If it's alphabetically good but better then next one */
|
||||
if(strcmp(psMapping->pName,test) < 0 && strcmp(psMapping->pName,psPresent->pName) > 0)
|
||||
{
|
||||
/* Keep a record of it */
|
||||
sstrcpy(test, psMapping->pName);
|
||||
psNext = psMapping;
|
||||
bGotOne = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* We found one matching criteria */
|
||||
if(bGotOne)
|
||||
{
|
||||
psPresent = psNext;
|
||||
bubbleCount++;
|
||||
sButInit.pUserData= psNext;
|
||||
widgAddButton(psWScreen, &sButInit);
|
||||
// move on..
|
||||
sButInit.id++;
|
||||
/* Might be no more room on the page */
|
||||
if ( (sButInit.y + KM_ENTRYH+5 ) > (3+ (BUTTONSPERKEYMAPPAGE*(KM_ENTRYH+3))))
|
||||
{
|
||||
sButInit.y = 16;
|
||||
sButInit.majorID += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
sButInit.y += KM_ENTRYH +3;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The previous one we found was alphabetically last - time to stop */
|
||||
bAtEnd = true;
|
||||
mappings.push_back(m);
|
||||
}
|
||||
}
|
||||
std::sort(mappings.begin(), mappings.end(), keyMappingSort);
|
||||
/* Add our first mapping to the form */
|
||||
/* Now add the others... */
|
||||
for (std::vector<KEY_MAPPING *>::const_iterator i = mappings.begin(); i != mappings.end(); ++i)
|
||||
{
|
||||
W_BUTTON *button = new W_BUTTON(kmList);
|
||||
button->id = KM_START + (i - mappings.begin());
|
||||
button->pUserData = *i;
|
||||
button->displayFunction = displayKeyMap;
|
||||
kmList->addWidgetToLayout(button);
|
||||
}
|
||||
|
||||
/* Stop when the right number or when aphabetically last - not sure...! */
|
||||
/* Go home... */
|
||||
return true;
|
||||
}
|
||||
|
|
107
src/loadsave.cpp
107
src/loadsave.cpp
|
@ -90,9 +90,8 @@
|
|||
#define SAVEENTRY_EDIT ID_LOADSAVE + totalslots + totalslots // save edit box. must be highest value possible I guess. -Q
|
||||
|
||||
// ////////////////////////////////////////////////////////////////////////////
|
||||
static void displayLoadBanner (WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
static void displayLoadSlot (WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
static void displayLoadSaveEdit (WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
static void displayLoadBanner(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset);
|
||||
static void displayLoadSlot(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset);
|
||||
|
||||
static W_SCREEN *psRequestScreen; // Widget screen for requester
|
||||
static bool mode;
|
||||
|
@ -191,32 +190,25 @@ bool addLoadSave(LOADSAVE_MODE savemode, const char *title)
|
|||
intRemoveReticule();
|
||||
}
|
||||
|
||||
psRequestScreen = widgCreateScreen(); // init the screen
|
||||
widgSetTipFont(psRequestScreen,font_regular);
|
||||
psRequestScreen = new W_SCREEN;
|
||||
|
||||
WIDGET *parent = psRequestScreen->psForm;
|
||||
|
||||
/* add a form to place the tabbed form on */
|
||||
W_FORMINIT sFormInit;
|
||||
sFormInit.formID = 0; //this adds the blue background, and the "box" behind the buttons -Q
|
||||
sFormInit.id = LOADSAVE_FORM;
|
||||
sFormInit.style = WFORM_PLAIN;
|
||||
sFormInit.x = (SWORD) LOADSAVE_X;
|
||||
sFormInit.y = (SWORD) LOADSAVE_Y;
|
||||
sFormInit.width = LOADSAVE_W;
|
||||
// we need the form to be long enough for all resolutions, so we take the total number of items * height
|
||||
// and * the gaps, add the banner, and finally, the fudge factor ;)
|
||||
sFormInit.height = (slotsInColumn * LOADENTRY_H + LOADSAVE_HGAP* slotsInColumn)+ LOADSAVE_BANNER_DEPTH+20;
|
||||
sFormInit.disableChildren = true;
|
||||
sFormInit.pDisplay = intOpenPlainForm;
|
||||
widgAddForm(psRequestScreen, &sFormInit);
|
||||
IntFormAnimated *loadSaveForm = new IntFormAnimated(parent);
|
||||
loadSaveForm->id = LOADSAVE_FORM;
|
||||
loadSaveForm->setGeometry(LOADSAVE_X, LOADSAVE_Y, LOADSAVE_W, slotsInColumn*(LOADENTRY_H + LOADSAVE_HGAP) + LOADSAVE_BANNER_DEPTH + 20);
|
||||
|
||||
// Add Banner
|
||||
W_FORMINIT sFormInit;
|
||||
sFormInit.formID = LOADSAVE_FORM;
|
||||
sFormInit.id = LOADSAVE_BANNER;
|
||||
sFormInit.x = LOADSAVE_HGAP;
|
||||
sFormInit.y = LOADSAVE_VGAP;
|
||||
sFormInit.width = LOADSAVE_W-(2*LOADSAVE_HGAP);
|
||||
sFormInit.height = LOADSAVE_BANNER_DEPTH;
|
||||
sFormInit.disableChildren = false;
|
||||
sFormInit.pDisplay = displayLoadBanner;
|
||||
sFormInit.UserData = bLoad;
|
||||
widgAddForm(psRequestScreen, &sFormInit);
|
||||
|
@ -335,7 +327,6 @@ bool addLoadSave(LOADSAVE_MODE savemode, const char *title)
|
|||
// ////////////////////////////////////////////////////////////////////////////
|
||||
bool closeLoadSave(void)
|
||||
{
|
||||
widgDelete(psRequestScreen,LOADSAVE_FORM);
|
||||
bLoadSaveUp = false;
|
||||
|
||||
if ((bLoadSaveMode == LOAD_INGAME_MISSION) || (bLoadSaveMode == SAVE_INGAME_MISSION)
|
||||
|
@ -356,7 +347,8 @@ bool closeLoadSave(void)
|
|||
intShowPowerBar();
|
||||
|
||||
}
|
||||
widgReleaseScreen(psRequestScreen);
|
||||
delete psRequestScreen;
|
||||
psRequestScreen = NULL;
|
||||
// need to "eat" up the return key so it don't pass back to game.
|
||||
inputLoseFocus();
|
||||
return true;
|
||||
|
@ -441,12 +433,13 @@ bool runLoadSave(bool bResetMissionWidgets)
|
|||
// clicked a load entry
|
||||
if( id >= LOADENTRY_START && id <= LOADENTRY_END )
|
||||
{
|
||||
W_BUTTON *slotButton = (W_BUTTON *)widgGetFromID(psRequestScreen, id);
|
||||
|
||||
if (mode) // Loading, return that entry.
|
||||
{
|
||||
if( ((W_BUTTON *)widgGetFromID(psRequestScreen,id))->pText )
|
||||
if (!slotButton->pText.isEmpty())
|
||||
{
|
||||
sprintf(sRequestResult, "%s%s%s", NewSaveGamePath, ((W_BUTTON *)widgGetFromID(psRequestScreen,id))->pText, sExt);
|
||||
ssprintf(sRequestResult, "%s%s%s", NewSaveGamePath, ((W_BUTTON *)widgGetFromID(psRequestScreen,id))->pText.toUtf8().constData(), sExt);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -460,39 +453,33 @@ bool runLoadSave(bool bResetMissionWidgets)
|
|||
|
||||
if( ! widgGetFromID(psRequestScreen,SAVEENTRY_EDIT))
|
||||
{
|
||||
// add blank box.
|
||||
W_EDBINIT sEdInit;
|
||||
sEdInit.formID= LOADSAVE_FORM;
|
||||
sEdInit.id = SAVEENTRY_EDIT;
|
||||
sEdInit.x = widgGetFromID(psRequestScreen,id)->x;
|
||||
sEdInit.y = widgGetFromID(psRequestScreen,id)->y;
|
||||
sEdInit.width = widgGetFromID(psRequestScreen,id)->width;
|
||||
sEdInit.height= widgGetFromID(psRequestScreen,id)->height;
|
||||
sEdInit.pText = ((W_BUTTON *)widgGetFromID(psRequestScreen,id))->pText;
|
||||
sEdInit.pBoxDisplay = displayLoadSaveEdit;
|
||||
widgAddEditBox(psRequestScreen, &sEdInit);
|
||||
WIDGET *parent = widgGetFromID(psRequestScreen, LOADSAVE_FORM);
|
||||
|
||||
if (((W_BUTTON *)widgGetFromID(psRequestScreen,id))->pText != NULL)
|
||||
// add blank box.
|
||||
W_EDITBOX *saveEntryEdit = new W_EDITBOX(parent);
|
||||
saveEntryEdit->id = SAVEENTRY_EDIT;
|
||||
saveEntryEdit->setGeometry(slotButton->geometry());
|
||||
saveEntryEdit->setString(slotButton->getString());
|
||||
saveEntryEdit->setBoxColours(WZCOL_MENU_LOAD_BORDER, WZCOL_MENU_LOAD_BORDER, WZCOL_MENU_BACKGROUND);
|
||||
|
||||
if (!slotButton->pText.isEmpty())
|
||||
{
|
||||
snprintf(sDelete, sizeof(sDelete), "%s%s%s", NewSaveGamePath,
|
||||
((W_BUTTON *)widgGetFromID(psRequestScreen,id))->pText, sExt);
|
||||
ssprintf(sDelete, "%s%s%s", NewSaveGamePath, slotButton->pText.toUtf8().constData(), sExt);
|
||||
}
|
||||
else
|
||||
{
|
||||
sstrcpy(sDelete, "");
|
||||
}
|
||||
|
||||
widgHide(psRequestScreen,id); // hide the old button
|
||||
slotButton->hide(); // hide the old button
|
||||
chosenSlotId = id;
|
||||
|
||||
// auto click in the edit box we just made.
|
||||
context.psScreen = psRequestScreen;
|
||||
context.psForm = (W_FORM *)psRequestScreen->psForm;
|
||||
context.xOffset = 0;
|
||||
context.yOffset = 0;
|
||||
context.mx = mouseX();
|
||||
context.my = mouseY();
|
||||
widgGetFromID(psRequestScreen, SAVEENTRY_EDIT)->clicked(&context);
|
||||
saveEntryEdit->clicked(&context);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -522,8 +509,8 @@ bool runLoadSave(bool bResetMissionWidgets)
|
|||
if( i != chosenSlotId)
|
||||
{
|
||||
|
||||
if( ((W_BUTTON *)widgGetFromID(psRequestScreen,i))->pText
|
||||
&& strcmp( sTemp, ((W_BUTTON *)widgGetFromID(psRequestScreen,i))->pText ) ==0)
|
||||
if(!((W_BUTTON *)widgGetFromID(psRequestScreen,i))->pText.isEmpty()
|
||||
&& strcmp(sTemp, ((W_BUTTON *)widgGetFromID(psRequestScreen,i))->pText.toUtf8().constData()) == 0)
|
||||
{
|
||||
widgDelete(psRequestScreen,SAVEENTRY_EDIT); //unselect this box, and go back ..
|
||||
widgReveal(psRequestScreen,chosenSlotId);
|
||||
|
@ -650,11 +637,11 @@ void removeWildcards(char *pStr)
|
|||
// ////////////////////////////////////////////////////////////////////////////
|
||||
// DISPLAY FUNCTIONS
|
||||
|
||||
static void displayLoadBanner(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours)
|
||||
static void displayLoadBanner(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
|
||||
{
|
||||
PIELIGHT col;
|
||||
UDWORD x = xOffset+psWidget->x;
|
||||
UDWORD y = yOffset+psWidget->y;
|
||||
int x = xOffset + psWidget->x();
|
||||
int y = yOffset + psWidget->y();
|
||||
|
||||
if(psWidget->pUserData)
|
||||
{
|
||||
|
@ -665,28 +652,27 @@ static void displayLoadBanner(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset,
|
|||
col = WZCOL_MENU_LOAD_BORDER;
|
||||
}
|
||||
|
||||
pie_BoxFill(x, y, x + psWidget->width, y + psWidget->height, col);
|
||||
pie_BoxFill(x + 2,y + 2, x + psWidget->width - 2, y + psWidget->height - 2, WZCOL_MENU_BACKGROUND);
|
||||
pie_BoxFill(x, y, x + psWidget->width(), y + psWidget->height(), col);
|
||||
pie_BoxFill(x + 2,y + 2, x + psWidget->width() - 2, y + psWidget->height() - 2, WZCOL_MENU_BACKGROUND);
|
||||
}
|
||||
|
||||
// ////////////////////////////////////////////////////////////////////////////
|
||||
static void displayLoadSlot(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours)
|
||||
static void displayLoadSlot(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
|
||||
{
|
||||
|
||||
UDWORD x = xOffset+psWidget->x;
|
||||
UDWORD y = yOffset+psWidget->y;
|
||||
int x = xOffset + psWidget->x();
|
||||
int y = yOffset + psWidget->y();
|
||||
char butString[64];
|
||||
|
||||
drawBlueBox(x,y,psWidget->width,psWidget->height); //draw box
|
||||
drawBlueBox(x, y, psWidget->width(), psWidget->height()); //draw box
|
||||
|
||||
if(((W_BUTTON *)psWidget)->pText )
|
||||
if (!((W_BUTTON *)psWidget)->pText.isEmpty())
|
||||
{
|
||||
sstrcpy(butString, ((W_BUTTON *)psWidget)->pText);
|
||||
sstrcpy(butString, ((W_BUTTON *)psWidget)->pText.toUtf8().constData());
|
||||
|
||||
iV_SetFont(font_regular); // font
|
||||
iV_SetTextColour(WZCOL_FORM_TEXT);
|
||||
|
||||
while(iV_GetTextWidth(butString) > psWidget->width)
|
||||
while(iV_GetTextWidth(butString) > psWidget->width())
|
||||
{
|
||||
butString[strlen(butString)-1]='\0';
|
||||
}
|
||||
|
@ -696,19 +682,6 @@ static void displayLoadSlot(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ
|
|||
}
|
||||
}
|
||||
|
||||
// ////////////////////////////////////////////////////////////////////////////
|
||||
static void displayLoadSaveEdit(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours)
|
||||
{
|
||||
UDWORD x = xOffset+psWidget->x;
|
||||
UDWORD y = yOffset+psWidget->y;
|
||||
UDWORD w = psWidget->width;
|
||||
UDWORD h = psWidget->height;
|
||||
|
||||
pie_BoxFill(x, y, x + w, y + h, WZCOL_MENU_LOAD_BORDER);
|
||||
pie_BoxFill(x + 1, y + 1, x + w - 1, y + h - 1, WZCOL_MENU_BACKGROUND);
|
||||
}
|
||||
|
||||
// ////////////////////////////////////////////////////////////////////////////
|
||||
void drawBlueBox(UDWORD x,UDWORD y, UDWORD w, UDWORD h)
|
||||
{
|
||||
pie_BoxFill(x - 1, y - 1, x + w + 1, y + h + 1, WZCOL_MENU_BORDER);
|
||||
|
|
|
@ -146,8 +146,6 @@ static GAMECODE renderLoop()
|
|||
intAddInGamePopup();
|
||||
}
|
||||
|
||||
HandleClosingWindows(); // Needs to be done outside the pause case.
|
||||
|
||||
audio_Update();
|
||||
|
||||
wzShowMouse(true);
|
||||
|
|
|
@ -576,7 +576,7 @@ void addTransporterTimerInterface(void)
|
|||
psForm = (W_CLICKFORM *)widgGetFromID(psWScreen, IDTRANTIMER_BUTTON);
|
||||
if (psForm)
|
||||
{
|
||||
formSetClickState(psForm, WBUT_LOCK);
|
||||
psForm->setState(WBUT_LOCK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1848,9 +1848,8 @@ void missionMoveTransporterOffWorld(DROID *psTransporter)
|
|||
psForm = (W_CLICKFORM *)widgGetFromID(psWScreen, IDTRANTIMER_BUTTON);
|
||||
if (psForm)
|
||||
{
|
||||
formSetClickState(psForm, WCLICK_NORMAL);
|
||||
psForm->setState(WBUT_PLAIN);
|
||||
}
|
||||
|
||||
}
|
||||
//need a callback for when all the selectedPlayers' reinforcements have been delivered
|
||||
if (psTransporter->player == selectedPlayer)
|
||||
|
@ -1999,8 +1998,9 @@ UDWORD missionGetReinforcementTime(void)
|
|||
}
|
||||
|
||||
//fills in a hours(if bHours = true), minutes and seconds display for a given time in 1000th sec
|
||||
static void fillTimeDisplay(char *psText, UDWORD time, bool bHours)
|
||||
static void fillTimeDisplay(QString &text, UDWORD time, bool bHours)
|
||||
{
|
||||
char psText[100];
|
||||
//this is only for the transporter timer - never have hours!
|
||||
if (time == LZ_COMPROMISED_TIME)
|
||||
{
|
||||
|
@ -2010,8 +2010,9 @@ static void fillTimeDisplay(char *psText, UDWORD time, bool bHours)
|
|||
{
|
||||
time_t secs = time / GAME_TICKS_PER_SEC;
|
||||
struct tm *tmp = localtime(&secs);
|
||||
strftime(psText, WIDG_MAXSTR, bHours ? "%H:%M:%S" : "%H:%M", tmp);
|
||||
strftime(psText, sizeof(psText), bHours ? "%H:%M:%S" : "%H:%M", tmp);
|
||||
}
|
||||
text = QString::fromUtf8(psText);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2046,7 +2047,7 @@ void intUpdateMissionTimer(WIDGET *psWidget, W_CONTEXT *psContext)
|
|||
}
|
||||
|
||||
fillTimeDisplay(Label->aText, timeRemaining, true);
|
||||
Label->style &= ~WIDG_HIDDEN; // Make sure its visible
|
||||
Label->show(); // Make sure its visible
|
||||
|
||||
if (challengeActive)
|
||||
{
|
||||
|
@ -2182,7 +2183,7 @@ void intUpdateTransporterTimer(WIDGET *psWidget, W_CONTEXT *psContext)
|
|||
Label->aText[3] = (UBYTE)('0'+ calcTime / 10);
|
||||
Label->aText[4] = (UBYTE)('0'+ calcTime % 10);*/
|
||||
|
||||
Label->style &= ~WIDG_HIDDEN;
|
||||
Label->show();
|
||||
}
|
||||
|
||||
/* Remove the Mission Timer widgets from the screen*/
|
||||
|
@ -2215,7 +2216,7 @@ void intRemoveTransporterTimer(void)
|
|||
|
||||
|
||||
|
||||
static void intDisplayMissionBackDrop(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours)
|
||||
static void intDisplayMissionBackDrop(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
|
||||
{
|
||||
scoreDataToScreen();
|
||||
}
|
||||
|
@ -2250,48 +2251,19 @@ static bool _intAddMissionResult(bool result, bool bPlaySuccess)
|
|||
sFormInit.formID = 0;
|
||||
sFormInit.id = IDMISSIONRES_BACKFORM;
|
||||
sFormInit.style = WFORM_PLAIN;
|
||||
sFormInit.x = (SWORD)(0 + D_W);
|
||||
sFormInit.y = (SWORD)(0 + D_H);
|
||||
sFormInit.width = 640;
|
||||
sFormInit.height = 480;
|
||||
sFormInit.pDisplay = intDisplayMissionBackDrop;
|
||||
if (!widgAddForm(psWScreen, &sFormInit))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
W_FORM *missionResBackForm = widgAddForm(psWScreen, &sFormInit);
|
||||
missionResBackForm->setGeometry(0 + D_W, 0 + D_H, 640, 480);
|
||||
|
||||
// TITLE
|
||||
sFormInit.formID = IDMISSIONRES_BACKFORM;
|
||||
|
||||
sFormInit.id = IDMISSIONRES_TITLE;
|
||||
sFormInit.style = WFORM_PLAIN;
|
||||
sFormInit.x = MISSIONRES_TITLE_X;
|
||||
sFormInit.y = MISSIONRES_TITLE_Y;
|
||||
sFormInit.width = MISSIONRES_TITLE_W;
|
||||
sFormInit.height = MISSIONRES_TITLE_H;
|
||||
sFormInit.disableChildren = true;
|
||||
sFormInit.pDisplay = intOpenPlainForm; //intDisplayPlainForm;
|
||||
|
||||
if (!widgAddForm(psWScreen, &sFormInit))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
IntFormAnimated *missionResTitle = new IntFormAnimated(missionResBackForm);
|
||||
missionResTitle->id = IDMISSIONRES_TITLE;
|
||||
missionResTitle->setGeometry(MISSIONRES_TITLE_X, MISSIONRES_TITLE_Y, MISSIONRES_TITLE_W, MISSIONRES_TITLE_H);
|
||||
|
||||
// add form
|
||||
sFormInit.formID = IDMISSIONRES_BACKFORM;
|
||||
|
||||
sFormInit.id = IDMISSIONRES_FORM;
|
||||
sFormInit.style = WFORM_PLAIN;
|
||||
sFormInit.x = MISSIONRES_X;
|
||||
sFormInit.y = MISSIONRES_Y;
|
||||
sFormInit.width = MISSIONRES_W;
|
||||
sFormInit.height = MISSIONRES_H;
|
||||
sFormInit.disableChildren = true;
|
||||
sFormInit.pDisplay = intOpenPlainForm; //intDisplayPlainForm;
|
||||
if (!widgAddForm(psWScreen, &sFormInit))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
IntFormAnimated *missionResForm = new IntFormAnimated(missionResBackForm);
|
||||
missionResForm->id = IDMISSIONRES_FORM;
|
||||
missionResForm->setGeometry(MISSIONRES_X, MISSIONRES_Y, MISSIONRES_W, MISSIONRES_H);
|
||||
|
||||
// description of success/fail
|
||||
W_LABINIT sLabInit;
|
||||
|
|
1029
src/multiint.cpp
1029
src/multiint.cpp
File diff suppressed because it is too large
Load Diff
|
@ -26,6 +26,9 @@
|
|||
|
||||
#include "lib/netplay/netplay.h"
|
||||
#include "lib/widget/widgbase.h"
|
||||
#include "lib/widget/form.h"
|
||||
#include <QtCore/QSignalMapper>
|
||||
|
||||
|
||||
#define MAX_LEN_AI_NAME 40
|
||||
#define AI_CUSTOM 127
|
||||
|
@ -33,6 +36,52 @@
|
|||
#define AI_CLOSED -1
|
||||
#define AI_NOT_FOUND -99
|
||||
|
||||
|
||||
class MultibuttonWidget : public W_FORM
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MultibuttonWidget(WIDGET *parent, int value = -1);
|
||||
|
||||
virtual void display(int xOffset, int yOffset);
|
||||
virtual void geometryChanged();
|
||||
|
||||
void setLabel(char const *text);
|
||||
void addButton(int value, Image image, Image imageHighlight, char const *tip);
|
||||
void enable(bool enabled = true);
|
||||
void disable() { enable(false); }
|
||||
void setGap(int gap);
|
||||
int currentValue() const { return currentValue_; }
|
||||
|
||||
signals:
|
||||
void chosen(int);
|
||||
|
||||
public slots:
|
||||
void choose(int value);
|
||||
|
||||
private:
|
||||
void stateChanged();
|
||||
|
||||
protected:
|
||||
W_LABEL *label;
|
||||
std::vector<std::pair<W_BUTTON *, int> > buttons;
|
||||
QSignalMapper *mapper;
|
||||
int currentValue_;
|
||||
bool disabled;
|
||||
int gap_;
|
||||
bool lockCurrent;
|
||||
};
|
||||
|
||||
class MultichoiceWidget : public MultibuttonWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MultichoiceWidget(WIDGET *parent, int value = -1);
|
||||
};
|
||||
|
||||
|
||||
void readAIs(); ///< step 1, load AI definition files
|
||||
void loadMultiScripts(); ///< step 2, load the actual AI scripts
|
||||
const char *getAIName(int player); ///< only run this -after- readAIs() is called
|
||||
|
@ -79,8 +128,6 @@ void loadMapPreview(bool hideInterface);
|
|||
#define CON_SETTINGSWIDTH 200
|
||||
#define CON_SETTINGSHEIGHT 100
|
||||
|
||||
#define CON_PASSWORD_LABEL 10132
|
||||
|
||||
#define CON_OK 10101
|
||||
#define CON_OKX CON_SETTINGSWIDTH-MULTIOP_OKW*2-13
|
||||
#define CON_OKY CON_SETTINGSHEIGHT-MULTIOP_OKH-3
|
||||
|
@ -167,12 +214,6 @@ void loadMapPreview(bool hideInterface);
|
|||
#define MROW4 MROW3+MULTIOP_EDITBOXH
|
||||
#define MROW5 MROW4+38
|
||||
#define MROW6 MROW5+29
|
||||
#define MROW7 MROW6+29
|
||||
#define MROW8 MROW7+29
|
||||
#define MROW9 MROW8+29
|
||||
#define MROW10 MROW9+32
|
||||
#define MROW11 MROW10+36
|
||||
#define MROW12 MROW11+40
|
||||
|
||||
#define MCOL0 50
|
||||
#define MCOL1 (MCOL0+26+10) // rem 10 for 4 lines.
|
||||
|
@ -187,32 +228,14 @@ void loadMapPreview(bool hideInterface);
|
|||
#define MULTIOP_MAP_ICON 10258
|
||||
#define MULTIOP_MAP 10259
|
||||
|
||||
#define MULTIOP_CAMPAIGN 10261
|
||||
#define MULTIOP_SKIRMISH 10263
|
||||
|
||||
|
||||
#define MULTIOP_CLEAN 10267
|
||||
#define MULTIOP_BASE 10268
|
||||
#define MULTIOP_DEFENCE 10269
|
||||
|
||||
#define MULTIOP_ALLIANCE_N 10270
|
||||
#define MULTIOP_ALLIANCE_Y 10271
|
||||
#define MULTIOP_ALLIANCE_TEAMS 102710 //locked teams
|
||||
|
||||
#define MULTIOP_POWLEV_LOW 10272
|
||||
#define MULTIOP_POWLEV_MED 10273
|
||||
#define MULTIOP_POWLEV_HI 10274
|
||||
|
||||
#define MULTIOP_REFRESH 10275
|
||||
|
||||
#define MULTIOP_HOST 10276
|
||||
#define MULTIOP_HOST_BUT 0xf0f0
|
||||
#define MULTIOP_HOSTX 5
|
||||
|
||||
#define MULTIOP_FILTER_TOGGLE 30277
|
||||
|
||||
#define MULTIOP_STRUCTLIMITS 21277 // we are using 10277 already
|
||||
#define MULTIOP_LIMITS_BUT 0xf0d0
|
||||
|
||||
#define MULTIOP_CANCELX 6
|
||||
#define MULTIOP_CANCELY 6
|
||||
|
@ -249,7 +272,6 @@ void loadMapPreview(bool hideInterface);
|
|||
#define MULTIOP_SKSLIDE_END 102873 //10320
|
||||
|
||||
#define MULTIOP_MAP_PREVIEW 920000
|
||||
#define MULTIOP_MAP_BUT 920002
|
||||
|
||||
#define MULTIOP_PASSWORD 920010
|
||||
#define MULTIOP_PASSWORD_BUT 920012
|
||||
|
|
|
@ -58,7 +58,6 @@
|
|||
#define IDLIMITS 22000
|
||||
#define IDLIMITS_RETURN (IDLIMITS+1)
|
||||
#define IDLIMITS_OK (IDLIMITS+2)
|
||||
#define IDLIMITS_TABS (IDLIMITS+3)
|
||||
#define IDLIMITS_ENTRIES_START (IDLIMITS+4)
|
||||
#define IDLIMITS_ENTRIES_END (IDLIMITS+99)
|
||||
|
||||
|
@ -72,32 +71,11 @@
|
|||
|
||||
#define BARWIDTH 480
|
||||
#define BARHEIGHT 40
|
||||
#define BUTPERFORM 8
|
||||
|
||||
// ////////////////////////////////////////////////////////////////////////////
|
||||
// protos.
|
||||
|
||||
static void displayStructureBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
|
||||
// ////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static bool useStruct(UDWORD count,UDWORD i)
|
||||
{
|
||||
ASSERT(i < numStructureStats, "Bad structure for structure limit: %d", (int)i);
|
||||
|
||||
if(count >= (4*BUTPERFORM))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// now see if we loaded that stat..
|
||||
if(asStructLimits[0][i].globalLimit ==LOTS_OF)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
static void displayStructureBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset);
|
||||
|
||||
// ////////////////////////////////////////////////////////////////////////////
|
||||
static inline void freeLimitSet(void)
|
||||
|
@ -114,9 +92,6 @@ static inline void freeLimitSet(void)
|
|||
// ////////////////////////////////////////////////////////////////////////////
|
||||
bool startLimitScreen(void)
|
||||
{
|
||||
UDWORD numButtons = 0;
|
||||
UDWORD i;
|
||||
|
||||
addBackdrop();//background
|
||||
|
||||
// load stats...
|
||||
|
@ -148,7 +123,7 @@ bool startLimitScreen(void)
|
|||
{
|
||||
// reset the sliders..
|
||||
// it's a HACK since the actual limiter structure was cleared in the startMultiOptions function
|
||||
for (i = 0; i < numStructureStats ; ++i)
|
||||
for (unsigned i = 0; i < numStructureStats; ++i)
|
||||
{
|
||||
asStructLimits[0][i].limit = asStructLimits[0][i].globalLimit;
|
||||
}
|
||||
|
@ -164,22 +139,17 @@ bool startLimitScreen(void)
|
|||
|
||||
addSideText(FRONTEND_SIDETEXT1,LIMITSX-2,LIMITSY,"LIMITS"); // draw sidetext...
|
||||
|
||||
W_FORMINIT sFormInit;
|
||||
sFormInit.formID = FRONTEND_BACKDROP;
|
||||
sFormInit.id = IDLIMITS;
|
||||
sFormInit.style = WFORM_PLAIN;
|
||||
sFormInit.x = LIMITSX;
|
||||
sFormInit.y = LIMITSY;
|
||||
sFormInit.width = LIMITSW;
|
||||
sFormInit.height = LIMITSH;
|
||||
sFormInit.pDisplay = intDisplayPlainForm;
|
||||
widgAddForm(psWScreen, &sFormInit);
|
||||
WIDGET *parent = widgGetFromID(psWScreen, FRONTEND_BACKDROP);
|
||||
|
||||
IntFormAnimated *limitsForm = new IntFormAnimated(parent, false);
|
||||
limitsForm->id = IDLIMITS;
|
||||
limitsForm->setGeometry(LIMITSX, LIMITSY, LIMITSW, LIMITSH);
|
||||
|
||||
// return button.
|
||||
addMultiBut(psWScreen,IDLIMITS,IDLIMITS_RETURN,
|
||||
LIMITS_OKX-40,LIMITS_OKY,
|
||||
iV_GetImageWidth(FrontImages,IMAGE_RETURN),
|
||||
iV_GetImageHeight(FrontImages,IMAGE_RETURN),
|
||||
iV_GetImageWidth(FrontImages, IMAGE_NO),
|
||||
iV_GetImageHeight(FrontImages, IMAGE_NO),
|
||||
_("Apply Defaults and Return To Previous Screen"),IMAGE_NO,IMAGE_NO,true);
|
||||
|
||||
// ok button
|
||||
|
@ -189,81 +159,30 @@ bool startLimitScreen(void)
|
|||
iV_GetImageHeight(FrontImages,IMAGE_OK),
|
||||
_("Accept Settings"),IMAGE_OK,IMAGE_OK,true);
|
||||
|
||||
// Count the number of minor tabs needed
|
||||
numButtons = 0;
|
||||
|
||||
for(i=0;i<numStructureStats;i++ )
|
||||
{
|
||||
if(useStruct(numButtons,i))
|
||||
{
|
||||
numButtons++;
|
||||
}
|
||||
}
|
||||
|
||||
if(numButtons >(4*BUTPERFORM)) numButtons =(4*BUTPERFORM);
|
||||
|
||||
// add tab form..
|
||||
sFormInit = W_FORMINIT();
|
||||
sFormInit.formID = IDLIMITS;
|
||||
sFormInit.id = IDLIMITS_TABS;
|
||||
sFormInit.style = WFORM_TABBED;
|
||||
sFormInit.x = 50;
|
||||
sFormInit.y = 10;
|
||||
sFormInit.width = LIMITSW - 100;
|
||||
sFormInit.height =LIMITSH - 4;
|
||||
sFormInit.numMajor = numForms(numButtons, BUTPERFORM);
|
||||
sFormInit.majorPos = WFORM_TABTOP;
|
||||
sFormInit.minorPos = WFORM_TABNONE;
|
||||
sFormInit.majorSize = OBJ_TABWIDTH+3; //!!
|
||||
sFormInit.majorOffset = OBJ_TABOFFSET;
|
||||
sFormInit.tabVertOffset = (OBJ_TABHEIGHT/2); //(DES_TAB_HEIGHT/2)+2;
|
||||
sFormInit.tabMajorThickness = OBJ_TABHEIGHT;
|
||||
sFormInit.pUserData = &StandardTab;
|
||||
sFormInit.pTabDisplay = intDisplayTab;
|
||||
|
||||
// TABFIXME --unsure if needs fixing yet.
|
||||
for (i=0; i< sFormInit.numMajor; i++)
|
||||
{
|
||||
sFormInit.aNumMinors[i] = 1;
|
||||
}
|
||||
widgAddForm(psWScreen, &sFormInit);
|
||||
IntListTabWidget *limitsList = new IntListTabWidget(limitsForm);
|
||||
limitsList->setChildSize(BARWIDTH, BARHEIGHT);
|
||||
limitsList->setChildSpacing(5, 5);
|
||||
limitsList->setGeometry(50, 10, BARWIDTH, 370);
|
||||
|
||||
//Put the buttons on it
|
||||
W_FORMINIT sButInit;
|
||||
sButInit.formID = IDLIMITS_TABS;//IDLIMITS;
|
||||
sButInit.style = WFORM_PLAIN;
|
||||
sButInit.width = BARWIDTH;
|
||||
sButInit.height = BARHEIGHT;
|
||||
sButInit.pDisplay = displayStructureBar;
|
||||
sButInit.x = 2;
|
||||
sButInit.y = 5;
|
||||
sButInit.id = IDLIMITS_ENTRIES_START;
|
||||
int limitsButtonId = IDLIMITS_ENTRIES_START;
|
||||
|
||||
numButtons =0;
|
||||
for(i=0; i<numStructureStats ;i++)
|
||||
for (unsigned i = 0; i < numStructureStats; ++i)
|
||||
{
|
||||
if(useStruct(numButtons,i))
|
||||
if (asStructLimits[0][i].globalLimit != LOTS_OF)
|
||||
{
|
||||
numButtons++;
|
||||
sButInit.UserData= i;
|
||||
W_FORM *button = new W_FORM(limitsList);
|
||||
button->id = limitsButtonId;
|
||||
button->displayFunction = displayStructureBar;
|
||||
button->UserData = i;
|
||||
limitsList->addWidgetToLayout(button);
|
||||
++limitsButtonId;
|
||||
|
||||
widgAddForm(psWScreen, &sButInit);
|
||||
sButInit.id ++;
|
||||
|
||||
addFESlider(sButInit.id,sButInit.id-1, 290,11,
|
||||
addFESlider(limitsButtonId, limitsButtonId - 1, 290, 11,
|
||||
asStructLimits[0][i].globalLimit,
|
||||
asStructLimits[0][i].limit);
|
||||
sButInit.id ++;
|
||||
|
||||
if (sButInit.y + BARHEIGHT + 2 > (BUTPERFORM*(BARHEIGHT+2) - 4) )
|
||||
{
|
||||
sButInit.y = 5;
|
||||
sButInit.majorID += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
sButInit.y += BARHEIGHT +5;
|
||||
}
|
||||
++limitsButtonId;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -420,12 +339,12 @@ void applyLimitSet(void)
|
|||
|
||||
// ////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void displayStructureBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours)
|
||||
static void displayStructureBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
|
||||
{
|
||||
UDWORD x = xOffset+psWidget->x;
|
||||
UDWORD y = yOffset+psWidget->y;
|
||||
UDWORD w = psWidget->width;
|
||||
UDWORD h = psWidget->height;
|
||||
int x = xOffset + psWidget->x();
|
||||
int y = yOffset + psWidget->y();
|
||||
int w = psWidget->width();
|
||||
int h = psWidget->height();
|
||||
STRUCTURE_STATS *stat = asStructureStats + psWidget->UserData;
|
||||
Position position;
|
||||
Vector3i rotation;
|
||||
|
@ -436,7 +355,7 @@ static void displayStructureBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset
|
|||
drawBlueBox(x,y,w,h);
|
||||
|
||||
// draw image
|
||||
pie_SetGeometricOffset( x+35 ,y+(psWidget->height/2)+9);
|
||||
pie_SetGeometricOffset(x + 35, y + psWidget->height()/2 + 9);
|
||||
rotation.x = -15;
|
||||
rotation.y = ((realTime/45)%360) ; //45
|
||||
rotation.z = 0;
|
||||
|
@ -460,11 +379,11 @@ static void displayStructureBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset
|
|||
// draw name
|
||||
iV_SetFont(font_regular); // font
|
||||
iV_SetTextColour(WZCOL_TEXT_BRIGHT);
|
||||
iV_DrawText(_(getName(stat->pName)), x + 80, y + (psWidget->height / 2) + 3);
|
||||
iV_DrawText(_(getName(stat->pName)), x + 80, y + psWidget->height()/2 + 3);
|
||||
|
||||
// draw limit
|
||||
ssprintf(str, "%d", ((W_SLIDER *)widgGetFromID(psWScreen, psWidget->id + 1))->pos);
|
||||
iV_DrawText(str, x+270, y+(psWidget->height/2)+3);
|
||||
iV_DrawText(str, x + 270, y + psWidget->height()/2 + 3);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -68,10 +68,8 @@
|
|||
W_SCREEN *psRScreen; // requester stuff.
|
||||
|
||||
extern char MultiCustomMapsPath[PATH_MAX];
|
||||
extern void displayMultiBut(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
|
||||
bool MultiMenuUp = false;
|
||||
bool ClosingMultiMenu = false;
|
||||
bool DebugMenuUp = false;
|
||||
static UDWORD context = 0;
|
||||
UDWORD current_tech = 1;
|
||||
|
@ -116,7 +114,6 @@ UDWORD current_numplayers = 4;
|
|||
/// requester stuff.
|
||||
#define M_REQUEST_CLOSE (MULTIMENU+49)
|
||||
#define M_REQUEST (MULTIMENU+50)
|
||||
#define M_REQUEST_TAB (MULTIMENU+51)
|
||||
|
||||
#define M_REQUEST_C1 (MULTIMENU+61)
|
||||
#define M_REQUEST_C2 (MULTIMENU+62)
|
||||
|
@ -261,22 +258,22 @@ static LEVEL_DATASET *enumerateMultiMaps(bool first, unsigned camToUse, unsigned
|
|||
|
||||
// ////////////////////////////////////////////////////////////////////////////
|
||||
// ////////////////////////////////////////////////////////////////////////////
|
||||
void displayRequestOption(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours)
|
||||
void displayRequestOption(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
|
||||
{
|
||||
LEVEL_DATASET *mapData = (LEVEL_DATASET *)psWidget->pUserData;
|
||||
|
||||
UDWORD x = xOffset+psWidget->x;
|
||||
UDWORD y = yOffset+psWidget->y;
|
||||
int x = xOffset + psWidget->x();
|
||||
int y = yOffset + psWidget->y();
|
||||
char butString[255];
|
||||
|
||||
sstrcpy(butString, ((W_BUTTON *)psWidget)->pTip);
|
||||
sstrcpy(butString, ((W_BUTTON *)psWidget)->pTip.toUtf8().constData());
|
||||
|
||||
drawBlueBox(x,y,psWidget->width,psWidget->height); //draw box
|
||||
drawBlueBox(x, y, psWidget->width(), psWidget->height());
|
||||
|
||||
iV_SetFont(font_regular); // font
|
||||
iV_SetTextColour(WZCOL_TEXT_BRIGHT);
|
||||
|
||||
while(iV_GetTextWidth(butString) > psWidget->width -10 )
|
||||
while (iV_GetTextWidth(butString) > psWidget->width() - 10)
|
||||
{
|
||||
butString[strlen(butString)-1]='\0';
|
||||
}
|
||||
|
@ -301,7 +298,7 @@ void displayRequestOption(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIEL
|
|||
iV_SetFont(font_small);
|
||||
iV_SetTextColour(WZCOL_TEXT_DARK);
|
||||
sstrcpy(butString, hash.toString().c_str());
|
||||
while (iV_GetTextWidth(butString) > psWidget->width - 10 - (8 + mapData->players*6))
|
||||
while (iV_GetTextWidth(butString) > psWidget->width() - 10 - (8 + mapData->players*6))
|
||||
{
|
||||
butString[strlen(butString) - 1] = '\0';
|
||||
}
|
||||
|
@ -319,13 +316,13 @@ void displayRequestOption(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIEL
|
|||
// ////////////////////////////////////////////////////////////////////////////
|
||||
// ////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void displayCamTypeBut(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours)
|
||||
static void displayCamTypeBut(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
|
||||
{
|
||||
UDWORD x = xOffset+psWidget->x;
|
||||
UDWORD y = yOffset+psWidget->y;
|
||||
int x = xOffset + psWidget->x();
|
||||
int y = yOffset + psWidget->y();
|
||||
char buffer[8];
|
||||
|
||||
drawBlueBox(x,y,psWidget->width,psWidget->height); //draw box
|
||||
drawBlueBox(x, y, psWidget->width(), psWidget->height());
|
||||
sprintf(buffer, "T%i", (int)(psWidget->UserData));
|
||||
if ((unsigned int)(psWidget->UserData) == current_tech) {
|
||||
iV_SetTextColour(WZCOL_TEXT_BRIGHT);
|
||||
|
@ -335,13 +332,13 @@ static void displayCamTypeBut(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset,
|
|||
iV_DrawText(buffer, x+2, y+12);
|
||||
}
|
||||
|
||||
static void displayNumPlayersBut(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours)
|
||||
static void displayNumPlayersBut(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
|
||||
{
|
||||
UDWORD x = xOffset+psWidget->x;
|
||||
UDWORD y = yOffset+psWidget->y;
|
||||
int x = xOffset + psWidget->x();
|
||||
int y = yOffset + psWidget->y();
|
||||
char buffer[8];
|
||||
|
||||
drawBlueBox(x,y,psWidget->width,psWidget->height); //draw box
|
||||
drawBlueBox(x, y, psWidget->width(), psWidget->height());
|
||||
if ((unsigned int)(psWidget->UserData) == current_numplayers) {
|
||||
iV_SetTextColour(WZCOL_TEXT_BRIGHT);
|
||||
} else {
|
||||
|
@ -357,17 +354,6 @@ static void displayNumPlayersBut(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffse
|
|||
|
||||
}
|
||||
|
||||
#define NBTIPS 512
|
||||
|
||||
static unsigned int check_tip_index(unsigned int i) {
|
||||
if (i < NBTIPS) {
|
||||
return i;
|
||||
} else {
|
||||
debug(LOG_MAIN, "Tip window index too high (%ud)", i);
|
||||
return NBTIPS-1;
|
||||
}
|
||||
}
|
||||
|
||||
/** Searches in the given search directory for files ending with the
|
||||
* given extension. Then will create a window with buttons for each
|
||||
* found file.
|
||||
|
@ -380,12 +366,8 @@ static unsigned int check_tip_index(unsigned int i) {
|
|||
*/
|
||||
void addMultiRequest(const char* searchDir, const char* fileExtension, UDWORD mode, UBYTE mapCam, UBYTE numPlayers)
|
||||
{
|
||||
char** fileList;
|
||||
char** currFile;
|
||||
const unsigned int extensionLength = strlen(fileExtension);
|
||||
const unsigned int buttonsX = (mode == MULTIOP_MAP) ? 22 : 17;
|
||||
unsigned int numButtons, count, butPerForm, i;
|
||||
static char tips[NBTIPS][MAX_STR_LENGTH];
|
||||
|
||||
context = mode;
|
||||
if(mode == MULTIOP_MAP)
|
||||
|
@ -393,85 +375,22 @@ void addMultiRequest(const char* searchDir, const char* fileExtension, UDWORD mo
|
|||
current_tech = mapCam;
|
||||
current_numplayers = numPlayers;
|
||||
}
|
||||
fileList = PHYSFS_enumerateFiles(searchDir);
|
||||
char **fileList = PHYSFS_enumerateFiles(searchDir);
|
||||
|
||||
// Count number of required buttons
|
||||
numButtons = 0;
|
||||
for (currFile = fileList; *currFile != NULL; ++currFile)
|
||||
{
|
||||
const unsigned int fileNameLength = strlen(*currFile);
|
||||
psRScreen = new W_SCREEN; ///< move this to intinit or somewhere like that.. (close too.)
|
||||
|
||||
// Check to see if this file matches the given extension
|
||||
if (fileNameLength > extensionLength
|
||||
&& strcmp(&(*currFile)[fileNameLength - extensionLength], fileExtension) == 0)
|
||||
++numButtons;
|
||||
}
|
||||
|
||||
if (mode == MULTIOP_MAP) // if its a map, also look in the predone stuff.
|
||||
{
|
||||
bool first = true;
|
||||
while (enumerateMultiMaps(first, mapCam, numPlayers) != NULL)
|
||||
{
|
||||
first = false;
|
||||
numButtons++;
|
||||
}
|
||||
}
|
||||
|
||||
psRScreen = widgCreateScreen(); ///< move this to intinit or somewhere like that.. (close too.)
|
||||
widgSetTipFont(psRScreen,font_regular);
|
||||
|
||||
/* Calculate how many buttons will go on a single form */
|
||||
butPerForm = ((M_REQUEST_W - 0 - 4) / (R_BUT_W +4)) * ((M_REQUEST_H - 0- 4) / (R_BUT_H+ 4));
|
||||
WIDGET *parent = psRScreen->psForm;
|
||||
|
||||
/* add a form to place the tabbed form on */
|
||||
W_FORMINIT sFormInit;
|
||||
sFormInit.formID = 0;
|
||||
sFormInit.id = M_REQUEST;
|
||||
sFormInit.style = WFORM_PLAIN;
|
||||
sFormInit.x = (SWORD)(M_REQUEST_X+D_W);
|
||||
sFormInit.y = (SWORD)(M_REQUEST_Y+D_H);
|
||||
sFormInit.width = M_REQUEST_W;
|
||||
sFormInit.height = M_REQUEST_H;
|
||||
sFormInit.disableChildren = true;
|
||||
sFormInit.pDisplay = intOpenPlainForm;
|
||||
widgAddForm(psRScreen, &sFormInit);
|
||||
IntFormAnimated *requestForm = new IntFormAnimated(parent);
|
||||
requestForm->id = M_REQUEST;
|
||||
requestForm->setGeometry(M_REQUEST_X + D_W, M_REQUEST_Y + D_H, M_REQUEST_W, M_REQUEST_H);
|
||||
|
||||
/* Add the tabs */
|
||||
sFormInit = W_FORMINIT();
|
||||
sFormInit.formID = M_REQUEST;
|
||||
sFormInit.id = M_REQUEST_TAB;
|
||||
sFormInit.style = WFORM_TABBED;
|
||||
sFormInit.x = 2;
|
||||
sFormInit.y = 2;
|
||||
sFormInit.width = M_REQUEST_W;
|
||||
sFormInit.height = M_REQUEST_H-4;
|
||||
|
||||
sFormInit.numMajor = numForms(numButtons, butPerForm);
|
||||
|
||||
sFormInit.majorPos = WFORM_TABTOP;
|
||||
sFormInit.minorPos = WFORM_TABNONE;
|
||||
sFormInit.majorSize = OBJ_TABWIDTH+2;
|
||||
sFormInit.majorOffset = OBJ_TABOFFSET;
|
||||
sFormInit.tabVertOffset = (OBJ_TABHEIGHT/2);
|
||||
sFormInit.tabMajorThickness = OBJ_TABHEIGHT;
|
||||
sFormInit.pUserData = &StandardTab;
|
||||
sFormInit.pTabDisplay = intDisplayTab;
|
||||
|
||||
// TABFIXME:
|
||||
// This appears to be the map pick screen, when we have lots of maps
|
||||
// this will need to change.
|
||||
if (sFormInit.numMajor > MAX_TAB_STD_SHOWN)
|
||||
{
|
||||
ASSERT(sFormInit.numMajor < MAX_TAB_SMALL_SHOWN,"Too many maps! Need scroll tabs here.");
|
||||
sFormInit.pUserData = &SmallTab;
|
||||
sFormInit.majorSize /= 2;
|
||||
}
|
||||
|
||||
for (i = 0; i < sFormInit.numMajor; ++i)
|
||||
{
|
||||
sFormInit.aNumMinors[i] = 2;
|
||||
}
|
||||
widgAddForm(psRScreen, &sFormInit);
|
||||
// Add the button list.
|
||||
IntListTabWidget *requestList = new IntListTabWidget(requestForm);
|
||||
requestList->setChildSize(R_BUT_W, R_BUT_H);
|
||||
requestList->setChildSpacing(4, 4);
|
||||
requestList->setGeometry(2 + buttonsX, 2, M_REQUEST_W - buttonsX, M_REQUEST_H - 4);
|
||||
|
||||
// Add the close button.
|
||||
W_BUTINIT sButInit;
|
||||
|
@ -486,57 +405,40 @@ void addMultiRequest(const char* searchDir, const char* fileExtension, UDWORD mo
|
|||
sButInit.UserData = PACKDWORD_TRI(0,IMAGE_CLOSEHILIGHT , IMAGE_CLOSE);
|
||||
widgAddButton(psRScreen, &sButInit);
|
||||
|
||||
/* Put the buttons on it *//* Set up the button struct */
|
||||
sButInit = W_BUTINIT();
|
||||
sButInit.formID = M_REQUEST_TAB;
|
||||
sButInit.id = M_REQUEST_BUT;
|
||||
sButInit.x = buttonsX;
|
||||
sButInit.y = 4;
|
||||
sButInit.width = R_BUT_W;
|
||||
sButInit.height = R_BUT_H;
|
||||
sButInit.pUserData = NULL;
|
||||
sButInit.pDisplay = displayRequestOption;
|
||||
|
||||
for (currFile = fileList, count = 0; *currFile != NULL && count < (butPerForm * 4); ++currFile)
|
||||
// Put the buttons on it.
|
||||
int nextButtonId = M_REQUEST_BUT;
|
||||
for (char **currFile = fileList; *currFile != NULL; ++currFile)
|
||||
{
|
||||
const unsigned int tip_index = check_tip_index(sButInit.id - M_REQUEST_BUT);
|
||||
const unsigned int fileNameLength = strlen(*currFile);
|
||||
const unsigned int tipStringLength = fileNameLength - extensionLength;
|
||||
|
||||
// Check to see if this file matches the given extension
|
||||
if (!(fileNameLength > extensionLength)
|
||||
if (fileNameLength <= extensionLength
|
||||
|| strcmp(&(*currFile)[fileNameLength - extensionLength], fileExtension) != 0)
|
||||
continue;
|
||||
|
||||
char *withoutExtension = strdup(*currFile);
|
||||
withoutExtension[fileNameLength - extensionLength] = '\0';
|
||||
|
||||
// Set the tip and add the button
|
||||
W_BUTTON *button = new W_BUTTON(requestList);
|
||||
button->id = nextButtonId;
|
||||
button->setTip(withoutExtension);
|
||||
button->setString(withoutExtension);
|
||||
button->displayFunction = displayRequestOption;
|
||||
requestList->addWidgetToLayout(button);
|
||||
|
||||
// Copy all of the filename except for the extension into the tiptext string
|
||||
strlcpy(tips[tip_index], *currFile, MIN(tipStringLength + 1, sizeof(tips[tip_index])));
|
||||
|
||||
sButInit.pTip = tips[tip_index];
|
||||
sButInit.pText = tips[tip_index];
|
||||
|
||||
++count;
|
||||
widgAddButton(psRScreen, &sButInit);
|
||||
free(withoutExtension);
|
||||
|
||||
/* Update the init struct for the next button */
|
||||
sButInit.id += 1;
|
||||
sButInit.x = (SWORD)(sButInit.x + (R_BUT_W+ 4));
|
||||
if (sButInit.x + R_BUT_W+ 2 > M_REQUEST_W)
|
||||
{
|
||||
sButInit.x = buttonsX;
|
||||
sButInit.y = (SWORD)(sButInit.y +R_BUT_H + 4);
|
||||
}
|
||||
if (sButInit.y +R_BUT_H + 4 > M_REQUEST_H)
|
||||
{
|
||||
sButInit.y = 4;
|
||||
sButInit.majorID += 1;
|
||||
}
|
||||
++nextButtonId;
|
||||
}
|
||||
|
||||
// Make sure to return memory back to PhyscisFS
|
||||
PHYSFS_freeList(fileList);
|
||||
|
||||
multiRequestUp = true;
|
||||
hoverPreviewId = 0;
|
||||
|
||||
if(mode == MULTIOP_MAP)
|
||||
{
|
||||
LEVEL_DATASET *mapData;
|
||||
|
@ -545,42 +447,24 @@ void addMultiRequest(const char* searchDir, const char* fileExtension, UDWORD mo
|
|||
{
|
||||
first = false;
|
||||
|
||||
unsigned int tip_index = check_tip_index(sButInit.id-M_REQUEST_BUT);
|
||||
|
||||
// add number of players to string.
|
||||
sstrcpy(tips[tip_index], mapData->pName);
|
||||
W_BUTTON *button = new W_BUTTON(requestList);
|
||||
button->id = nextButtonId;
|
||||
button->setTip(mapData->pName);
|
||||
button->setString(mapData->pName);
|
||||
button->pUserData = mapData;
|
||||
button->displayFunction = displayRequestOption;
|
||||
requestList->addWidgetToLayout(button);
|
||||
|
||||
sButInit.pTip = tips[tip_index];
|
||||
sButInit.pText = tips[tip_index];
|
||||
sButInit.pUserData = mapData;
|
||||
|
||||
widgAddButton(psRScreen, &sButInit);
|
||||
|
||||
sButInit.id += 1;
|
||||
sButInit.x = (SWORD)(sButInit.x + (R_BUT_W+ 4));
|
||||
if (sButInit.x + R_BUT_W+ 2 > M_REQUEST_W)
|
||||
{
|
||||
sButInit.x = buttonsX;
|
||||
sButInit.y = (SWORD)(sButInit.y +R_BUT_H + 4);
|
||||
}
|
||||
if (sButInit.y +R_BUT_H + 4 > M_REQUEST_H)
|
||||
{
|
||||
sButInit.y = 4;
|
||||
sButInit.majorID += 1;
|
||||
}
|
||||
++nextButtonId;
|
||||
}
|
||||
}
|
||||
multiRequestUp = true;
|
||||
hoverPreviewId = 0;
|
||||
|
||||
// if it's map select then add the cam style buttons.
|
||||
if(mode == MULTIOP_MAP)
|
||||
{
|
||||
// if it's map select then add the cam style buttons.
|
||||
sButInit = W_BUTINIT();
|
||||
sButInit.formID = M_REQUEST_TAB;
|
||||
sButInit.formID = M_REQUEST;
|
||||
sButInit.id = M_REQUEST_C1;
|
||||
sButInit.x = 1;
|
||||
sButInit.y = 252;
|
||||
sButInit.x = 3;
|
||||
sButInit.y = 254;
|
||||
sButInit.width = 17;
|
||||
sButInit.height = 17;
|
||||
sButInit.UserData = 1;
|
||||
|
@ -624,14 +508,14 @@ void addMultiRequest(const char* searchDir, const char* fileExtension, UDWORD mo
|
|||
|
||||
static void closeMultiRequester(void)
|
||||
{
|
||||
widgDelete(psRScreen,M_REQUEST);
|
||||
multiRequestUp = false;
|
||||
resetReadyStatus(false);
|
||||
widgReleaseScreen(psRScreen); // move this to the frontend shutdown...
|
||||
delete psRScreen; // move this to the frontend shutdown...
|
||||
psRScreen = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
bool runMultiRequester(UDWORD id, UDWORD *mode, char *chosen, LEVEL_DATASET **chosenValue, bool *isHoverPreview)
|
||||
bool runMultiRequester(UDWORD id, UDWORD *mode, QString *chosen, LEVEL_DATASET **chosenValue, bool *isHoverPreview)
|
||||
{
|
||||
static unsigned hoverId = 0;
|
||||
static unsigned hoverStartTime = 0;
|
||||
|
@ -660,7 +544,7 @@ bool runMultiRequester(UDWORD id, UDWORD *mode, char *chosen, LEVEL_DATASET **ch
|
|||
}
|
||||
if (id >= M_REQUEST_BUT && id <= M_REQUEST_BUTM) // chose a file.
|
||||
{
|
||||
strcpy(chosen,((W_BUTTON *)widgGetFromID(psRScreen,id))->pText );
|
||||
*chosen = ((W_BUTTON *)widgGetFromID(psRScreen,id))->pText;
|
||||
|
||||
*chosenValue = (LEVEL_DATASET *)((W_BUTTON *)widgGetFromID(psRScreen,id))->pUserData;
|
||||
*mode = context;
|
||||
|
@ -802,16 +686,16 @@ static void displayExtraGubbins(UDWORD height)
|
|||
}
|
||||
|
||||
|
||||
static void displayMultiPlayer(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours)
|
||||
static void displayMultiPlayer(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
|
||||
{
|
||||
char str[128];
|
||||
int x = xOffset + psWidget->x;
|
||||
int y = yOffset + psWidget->y;
|
||||
int x = xOffset + psWidget->x();
|
||||
int y = yOffset + psWidget->y();
|
||||
unsigned player = psWidget->UserData; // Get the in game player number.
|
||||
|
||||
if (responsibleFor(player, 0))
|
||||
{
|
||||
displayExtraGubbins(widgGetFromID(psWScreen,MULTIMENU_FORM)->height);
|
||||
displayExtraGubbins(widgGetFromID(psWScreen,MULTIMENU_FORM)->height());
|
||||
}
|
||||
|
||||
iV_SetFont(font_regular); // font
|
||||
|
@ -987,11 +871,11 @@ static void displayMultiPlayer(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset,
|
|||
}
|
||||
}
|
||||
|
||||
static void displayDebugMenu(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours)
|
||||
static void displayDebugMenu(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
|
||||
{
|
||||
char str[128];
|
||||
UDWORD x = xOffset+psWidget->x;
|
||||
UDWORD y = yOffset+psWidget->y;
|
||||
int x = xOffset + psWidget->x();
|
||||
int y = yOffset + psWidget->y();
|
||||
UDWORD index = psWidget->UserData;
|
||||
|
||||
iV_SetFont(font_regular); // font
|
||||
|
@ -1008,7 +892,7 @@ static void displayDebugMenu(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, P
|
|||
// ////////////////////////////////////////////////////////////////////////////
|
||||
// alliance display funcs
|
||||
|
||||
static void displayAllianceState(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours)
|
||||
static void displayAllianceState(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
|
||||
{
|
||||
UDWORD a, b, c, player = psWidget->UserData;
|
||||
switch(alliances[selectedPlayer][player])
|
||||
|
@ -1037,11 +921,11 @@ static void displayAllianceState(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffse
|
|||
}
|
||||
|
||||
psWidget->UserData = PACKDWORD_TRI(a,b,c);
|
||||
intDisplayImageHilight(psWidget, xOffset, yOffset, pColours);
|
||||
intDisplayImageHilight(psWidget, xOffset, yOffset);
|
||||
psWidget->UserData = player;
|
||||
}
|
||||
|
||||
static void displayChannelState(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours)
|
||||
static void displayChannelState(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset)
|
||||
{
|
||||
UDWORD player = psWidget->UserData;
|
||||
|
||||
|
@ -1053,7 +937,7 @@ static void displayChannelState(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset
|
|||
{
|
||||
psWidget->UserData = PACKDWORD_TRI(0, IMAGE_MULTI_NOCHAN, IMAGE_MULTI_NOCHAN);
|
||||
}
|
||||
intDisplayImageHilight(psWidget, xOffset, yOffset, pColours);
|
||||
intDisplayImageHilight(psWidget, xOffset, yOffset);
|
||||
psWidget->UserData = player;
|
||||
}
|
||||
|
||||
|
@ -1210,22 +1094,12 @@ bool addDebugMenu(bool bAdd)
|
|||
formHeight += DEBUGMENU_ENTRY_H;
|
||||
}
|
||||
|
||||
// add form
|
||||
W_FORMINIT sFormInit;
|
||||
sFormInit.formID = 0;
|
||||
sFormInit.id = DEBUGMENU;
|
||||
sFormInit.style = WFORM_PLAIN;
|
||||
sFormInit.x =(SWORD)(DEBUGMENU_FORM_X);
|
||||
sFormInit.y =(SWORD)(DEBUGMENU_FORM_Y);
|
||||
sFormInit.width = DEBUGMENU_FORM_W;
|
||||
sFormInit.height = formHeight;
|
||||
sFormInit.pDisplay = intOpenPlainForm;
|
||||
sFormInit.disableChildren = true;
|
||||
WIDGET *parent = psWScreen->psForm;
|
||||
|
||||
if (!widgAddForm(psWScreen, &sFormInit))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// add form
|
||||
IntFormAnimated *debugMenu = new IntFormAnimated(parent);
|
||||
debugMenu->id = DEBUGMENU;
|
||||
debugMenu->setGeometry(DEBUGMENU_FORM_X, DEBUGMENU_FORM_Y, DEBUGMENU_FORM_W, formHeight);
|
||||
|
||||
// add debug info
|
||||
pos = 0;
|
||||
|
@ -1234,7 +1108,7 @@ bool addDebugMenu(bool bAdd)
|
|||
if(strcmp(debugMenuEntry[i],""))
|
||||
{
|
||||
// add form
|
||||
sFormInit = W_FORMINIT();
|
||||
W_FORMINIT sFormInit;
|
||||
sFormInit.formID = DEBUGMENU;
|
||||
sFormInit.id = DEBUGMENU_CLOSE + pos + 1;
|
||||
sFormInit.style = WFORM_PLAIN;
|
||||
|
@ -1289,22 +1163,12 @@ bool intAddMultiMenu(void)
|
|||
intResetScreen(false);
|
||||
}
|
||||
|
||||
// add form
|
||||
W_FORMINIT sFormInit;
|
||||
sFormInit.formID = 0;
|
||||
sFormInit.id = MULTIMENU_FORM;
|
||||
sFormInit.style = WFORM_PLAIN;
|
||||
sFormInit.x =(SWORD)(MULTIMENU_FORM_X);
|
||||
sFormInit.y =(SWORD)(MULTIMENU_FORM_Y);
|
||||
sFormInit.width = MULTIMENU_FORM_W;
|
||||
sFormInit.height = MULTIMENU_PLAYER_H*game.maxPlayers + MULTIMENU_PLAYER_H + 7;
|
||||
sFormInit.pDisplay = intOpenPlainForm;
|
||||
sFormInit.disableChildren = true;
|
||||
WIDGET *parent = psWScreen->psForm;
|
||||
|
||||
if (!widgAddForm(psWScreen, &sFormInit))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// add form
|
||||
IntFormAnimated *multiMenuForm = new IntFormAnimated(parent);
|
||||
multiMenuForm->id = MULTIMENU_FORM;
|
||||
multiMenuForm->setGeometry(MULTIMENU_FORM_X, MULTIMENU_FORM_Y, MULTIMENU_FORM_W, MULTIMENU_PLAYER_H*game.maxPlayers + MULTIMENU_PLAYER_H + 7);
|
||||
|
||||
// add any players
|
||||
for(i=0;i<MAX_PLAYERS;i++)
|
||||
|
@ -1344,12 +1208,11 @@ bool intAddMultiMenu(void)
|
|||
// ////////////////////////////////////////////////////////////////////////////
|
||||
void intCloseMultiMenuNoAnim(void)
|
||||
{
|
||||
if (!MultiMenuUp && !ClosingMultiMenu)
|
||||
widgDelete(psWScreen, MULTIMENU_FORM);
|
||||
if (!MultiMenuUp)
|
||||
{
|
||||
return;
|
||||
}
|
||||
widgDelete(psWScreen, MULTIMENU_CLOSE);
|
||||
widgDelete(psWScreen, MULTIMENU_FORM);
|
||||
MultiMenuUp = false;
|
||||
if (intMode != INT_INTELMAP)
|
||||
{
|
||||
|
@ -1361,22 +1224,16 @@ void intCloseMultiMenuNoAnim(void)
|
|||
// ////////////////////////////////////////////////////////////////////////////
|
||||
bool intCloseMultiMenu(void)
|
||||
{
|
||||
W_TABFORM *Form;
|
||||
|
||||
if (!MultiMenuUp)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
widgDelete(psWScreen, MULTIMENU_CLOSE);
|
||||
|
||||
// Start the window close animation.
|
||||
Form = (W_TABFORM*)widgGetFromID(psWScreen,MULTIMENU_FORM);
|
||||
if(Form) {
|
||||
Form->display = intClosePlainForm;
|
||||
Form->pUserData = NULL; // Used to signal when the close anim has finished.
|
||||
Form->disableChildren = true;
|
||||
ClosingMultiMenu = true;
|
||||
IntFormAnimated *form = (IntFormAnimated *)widgGetFromID(psWScreen, MULTIMENU_FORM);
|
||||
if (form != nullptr)
|
||||
{
|
||||
form->closeAnimateDelete();
|
||||
MultiMenuUp = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,8 +31,8 @@
|
|||
extern void addMultiRequest(const char* searchDir, const char* fileExtension, UDWORD id,UBYTE mapCam, UBYTE numPlayers);
|
||||
extern bool multiRequestUp;
|
||||
extern W_SCREEN *psRScreen; // requester stuff.
|
||||
bool runMultiRequester(UDWORD id, UDWORD *mode, char *chosen, LEVEL_DATASET **chosenValue, bool *isHoverPreview);
|
||||
extern void displayRequestOption(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
|
||||
bool runMultiRequester(UDWORD id, UDWORD *mode, QString *chosen, LEVEL_DATASET **chosenValue, bool *isHoverPreview);
|
||||
void displayRequestOption(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset);
|
||||
|
||||
// multimenu
|
||||
extern void intProcessMultiMenu (UDWORD id);
|
||||
|
@ -46,7 +46,6 @@ extern void intCloseDebugMenuNoAnim (void);
|
|||
extern void setDebugMenuEntry(char *entry, SDWORD index);
|
||||
|
||||
extern bool MultiMenuUp;
|
||||
extern bool ClosingMultiMenu;
|
||||
|
||||
extern bool DebugMenuUp;
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
* Code to deal with loading/unloading, interface and flight of transporters.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "lib/framework/frame.h"
|
||||
#include "lib/framework/strres.h"
|
||||
|
@ -58,9 +59,7 @@
|
|||
#include "qtscript.h"
|
||||
|
||||
//#define IDTRANS_FORM 9000 //The Transporter base form
|
||||
#define IDTRANS_TABFORM 9001 //The Transporter tabbed form
|
||||
#define IDTRANS_CLOSE 9002 //The close button icon
|
||||
#define IDTRANS_CONTABFORM 9004 //The Transporter Contents tabbed form
|
||||
#define IDTRANS_CONTCLOSE 9005 //The close icon on the Contents form
|
||||
#define IDTRANS_DROIDTAB 9007 //The Droid tab form
|
||||
#define IDTRANS_DROIDCLOSE 9008 //The close icon for the Droid form
|
||||
|
@ -83,10 +82,7 @@
|
|||
#define TRANS_HEIGHT OBJ_BACKHEIGHT
|
||||
|
||||
/*tabbed form screen positions */
|
||||
#define TRANS_TABX OBJ_TABX
|
||||
#define TRANS_TABY OBJ_TABY
|
||||
#define TRANS_TABWIDTH OBJ_WIDTH
|
||||
#define TRANS_TABHEIGHT OBJ_HEIGHT
|
||||
|
||||
/*Transported contents screen positions */
|
||||
#define TRANSCONT_X STAT_X
|
||||
|
@ -95,7 +91,6 @@
|
|||
#define TRANSCONT_HEIGHT STAT_HEIGHT
|
||||
|
||||
/*contents tabbed form screen positions */
|
||||
#define TRANSCONT_TABX STAT_TABFORMX
|
||||
#define TRANSCONT_TABY STAT_TABFORMY
|
||||
|
||||
/*droid form screen positions */
|
||||
|
@ -104,12 +99,6 @@
|
|||
#define TRANSDROID_WIDTH STAT_WIDTH
|
||||
#define TRANSDROID_HEIGHT STAT_HEIGHT
|
||||
|
||||
/*droid Tab form screen positions */
|
||||
#define TRANSDROID_TABX STAT_TABFORMX
|
||||
#define TRANSDROID_TABY STAT_TABFORMY
|
||||
#define TRANSDROID_TABWIDTH STAT_WIDTH
|
||||
#define TRANSDROID_TABHEIGHT STAT_HEIGHT
|
||||
|
||||
//start y position of the available droids buttons
|
||||
#define AVAIL_STARTY 0
|
||||
|
||||
|
@ -119,9 +108,6 @@
|
|||
#define MEDIUM_DROID 2
|
||||
#define HEAVY_DROID 3
|
||||
|
||||
//max that can be available from home
|
||||
|
||||
#define MAX_DROIDS 80
|
||||
|
||||
/* the widget screen */
|
||||
extern W_SCREEN *psWScreen;
|
||||
|
@ -134,7 +120,7 @@ static UDWORD g_iLaunchTime = 0;
|
|||
//used for audio message for reinforcements
|
||||
static bool bFirstTransporter;
|
||||
//the tab positions of the DroidsAvail window
|
||||
static UWORD objMajor = 0, objMinor = 0;
|
||||
static UWORD objMajor = 0;
|
||||
|
||||
/*functions */
|
||||
static bool intAddTransporterContents(void);
|
||||
|
@ -219,30 +205,11 @@ static bool _intAddTransporter(DROID *psSelected, bool offWorld)
|
|||
Animate = false;
|
||||
}
|
||||
|
||||
W_FORMINIT sFormInit;
|
||||
sFormInit.formID = 0;
|
||||
sFormInit.id = IDTRANS_FORM;
|
||||
sFormInit.style = WFORM_PLAIN;
|
||||
sFormInit.x = (SWORD)TRANS_X;
|
||||
sFormInit.y = (SWORD)TRANS_Y;
|
||||
sFormInit.width = TRANS_WIDTH;
|
||||
sFormInit.height = TRANS_HEIGHT;
|
||||
// If the window was closed then do open animation.
|
||||
if (Animate)
|
||||
{
|
||||
sFormInit.pDisplay = intOpenPlainForm;
|
||||
sFormInit.disableChildren = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// otherwise just recreate it.
|
||||
sFormInit.pDisplay = intDisplayPlainForm;
|
||||
}
|
||||
WIDGET *parent = psWScreen->psForm;
|
||||
|
||||
if (!widgAddForm(psWScreen, &sFormInit))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
IntFormAnimated *transForm = new IntFormAnimated(parent, Animate); // Do not animate the opening, if the window was already open.
|
||||
transForm->id = IDTRANS_FORM;
|
||||
transForm->setGeometry(TRANS_X, TRANS_Y, TRANS_WIDTH, TRANS_HEIGHT);
|
||||
|
||||
/* Add the close button */
|
||||
W_BUTINIT sButInit;
|
||||
|
@ -300,30 +267,11 @@ bool intAddTransporterContents(void)
|
|||
Animate = false;
|
||||
}
|
||||
|
||||
W_FORMINIT sFormInit;
|
||||
sFormInit.formID = 0;
|
||||
sFormInit.id = IDTRANS_CONTENTFORM;
|
||||
sFormInit.style = WFORM_PLAIN;
|
||||
sFormInit.x = (SWORD)TRANSCONT_X;
|
||||
sFormInit.y = (SWORD)TRANSCONT_Y;
|
||||
sFormInit.width = TRANSCONT_WIDTH;
|
||||
sFormInit.height = TRANSCONT_HEIGHT;
|
||||
// If the window was closed then do open animation.
|
||||
if (Animate)
|
||||
{
|
||||
sFormInit.pDisplay = intOpenPlainForm;
|
||||
sFormInit.disableChildren = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// otherwise just recreate it.
|
||||
sFormInit.pDisplay = intDisplayPlainForm;
|
||||
}
|
||||
WIDGET *parent = psWScreen->psForm;
|
||||
|
||||
if (!widgAddForm(psWScreen, &sFormInit))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
IntFormAnimated *transContentForm = new IntFormAnimated(parent, Animate); // Do not animate the opening, if the window was already open.
|
||||
transContentForm->id = IDTRANS_CONTENTFORM;
|
||||
transContentForm->setGeometry(TRANSCONT_X, TRANSCONT_Y, TRANSCONT_WIDTH, TRANSCONT_HEIGHT);
|
||||
|
||||
/* Add the close button */
|
||||
W_BUTINIT sButInit;
|
||||
|
@ -474,154 +422,65 @@ void intRemoveTransporterLaunch(void)
|
|||
/* Add the Transporter Button form */
|
||||
bool intAddTransButtonForm(void)
|
||||
{
|
||||
UDWORD numButtons, i;
|
||||
SDWORD BufferID;
|
||||
DROID *psDroid;
|
||||
WIDGET *transForm = widgGetFromID(psWScreen, IDTRANS_FORM);
|
||||
|
||||
/* Add the button form */
|
||||
W_FORMINIT sFormInit;
|
||||
sFormInit.formID = IDTRANS_FORM;
|
||||
sFormInit.id = IDTRANS_TABFORM;
|
||||
sFormInit.style = WFORM_TABBED;
|
||||
sFormInit.width = TRANS_TABWIDTH;
|
||||
sFormInit.height = TRANS_TABHEIGHT;
|
||||
sFormInit.x = TRANS_TABX;
|
||||
sFormInit.y = TRANS_TABY;
|
||||
|
||||
sFormInit.majorPos = WFORM_TABTOP;
|
||||
sFormInit.minorPos = WFORM_TABNONE;
|
||||
sFormInit.majorSize = OBJ_TABWIDTH;
|
||||
sFormInit.majorOffset = OBJ_TABOFFSET;
|
||||
sFormInit.tabVertOffset = (OBJ_TABHEIGHT / 2);
|
||||
sFormInit.tabMajorThickness = OBJ_TABHEIGHT;
|
||||
|
||||
numButtons = 0;
|
||||
/*work out the number of buttons */
|
||||
for (psDroid = transInterfaceDroidList(); psDroid; psDroid = psDroid->psNext)
|
||||
{
|
||||
//only interested in Transporter droids
|
||||
if ((psDroid->droidType == DROID_TRANSPORTER || psDroid->droidType == DROID_SUPERTRANSPORTER) &&
|
||||
(psDroid->action != DACTION_TRANSPORTOUT &&
|
||||
psDroid->action != DACTION_TRANSPORTIN))
|
||||
{
|
||||
//set the first Transporter to be the current one if not already set
|
||||
if (psCurrTransporter == NULL)
|
||||
{
|
||||
psCurrTransporter = psDroid;
|
||||
}
|
||||
numButtons++;
|
||||
}
|
||||
}
|
||||
|
||||
//set the number of tabs required
|
||||
sFormInit.numMajor = numForms((OBJ_BUTWIDTH + OBJ_GAP) * numButtons, OBJ_WIDTH - OBJ_GAP);
|
||||
|
||||
sFormInit.pUserData = &StandardTab;
|
||||
sFormInit.pTabDisplay = intDisplayTab;
|
||||
|
||||
if (sFormInit.numMajor > MAX_TAB_STD_SHOWN)
|
||||
{
|
||||
// we do NOT use smallTab icons here, so be safe and only display max # of
|
||||
// standard sized tab icons.
|
||||
sFormInit.numMajor = MAX_TAB_STD_SHOWN;
|
||||
}
|
||||
//set minor tabs to 1
|
||||
for (i = 0; i < sFormInit.numMajor; i++)
|
||||
{
|
||||
sFormInit.aNumMinors[i] = 1;
|
||||
}
|
||||
|
||||
if (!widgAddForm(psWScreen, &sFormInit))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
IntListTabWidget *transList = new IntListTabWidget(transForm);
|
||||
transList->setChildSize(OBJ_BUTWIDTH, OBJ_BUTHEIGHT*2);
|
||||
transList->setChildSpacing(OBJ_GAP, OBJ_GAP);
|
||||
int objListWidth = OBJ_BUTWIDTH*5 + OBJ_GAP*4;
|
||||
transList->setGeometry((OBJ_BACKWIDTH - objListWidth)/2, TRANS_TABY, objListWidth, transForm->height() - TRANS_TABY);
|
||||
|
||||
/* Add the transporter and status buttons */
|
||||
W_FORMINIT sBFormInit;
|
||||
sBFormInit.formID = IDTRANS_TABFORM;
|
||||
sBFormInit.id = IDTRANS_START;
|
||||
sBFormInit.majorID = 0;
|
||||
sBFormInit.minorID = 0;
|
||||
sBFormInit.style = WFORM_CLICKABLE;
|
||||
sBFormInit.x = OBJ_STARTX;
|
||||
sBFormInit.y = OBJ_STARTY;
|
||||
sBFormInit.width = OBJ_BUTWIDTH;
|
||||
sBFormInit.height = OBJ_BUTHEIGHT;
|
||||
|
||||
W_FORMINIT sBFormInit2 = sBFormInit;
|
||||
sBFormInit2.id = IDTRANS_STATSTART;
|
||||
sBFormInit2.y = OBJ_STATSTARTY;
|
||||
|
||||
ClearObjectBuffers();
|
||||
ClearTopicBuffers();
|
||||
int nextObjButtonId = IDTRANS_START;
|
||||
int nextStatButtonId = IDTRANS_STATSTART;
|
||||
|
||||
//add each button
|
||||
for (psDroid = transInterfaceDroidList(); psDroid; psDroid = psDroid->psNext)
|
||||
for (DROID *psDroid = transInterfaceDroidList(); psDroid; psDroid = psDroid->psNext)
|
||||
{
|
||||
if ((psDroid->droidType == DROID_TRANSPORTER || psDroid->droidType == DROID_SUPERTRANSPORTER) &&
|
||||
(psDroid->action != DACTION_TRANSPORTOUT &&
|
||||
psDroid->action != DACTION_TRANSPORTIN))
|
||||
if ((psDroid->droidType != DROID_TRANSPORTER && psDroid->droidType != DROID_SUPERTRANSPORTER) ||
|
||||
psDroid->action == DACTION_TRANSPORTOUT || psDroid->action == DACTION_TRANSPORTIN)
|
||||
{
|
||||
/* Set the tip and add the button */
|
||||
sBFormInit.pTip = droidGetName(psDroid);
|
||||
|
||||
BufferID = sBFormInit.id - IDTRANS_START;
|
||||
ASSERT(BufferID < NUM_TOPICBUFFERS, "BufferID > NUM_TOPICBUFFERS");
|
||||
ClearTopicButtonBuffer(BufferID);
|
||||
RENDERBUTTON_INUSE(&TopicBuffers[BufferID]);
|
||||
TopicBuffers[BufferID].Data = (void *)psDroid;
|
||||
sBFormInit.pUserData = &TopicBuffers[BufferID];
|
||||
sBFormInit.pDisplay = intDisplayObjectButton;
|
||||
|
||||
if (!widgAddForm(psWScreen, &sBFormInit))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* if the current droid matches psCurrTransporter lock the button */
|
||||
if (psDroid == psCurrTransporter)
|
||||
{
|
||||
widgSetButtonState(psWScreen, sBFormInit.id, WBUT_LOCK);
|
||||
widgSetTabs(psWScreen, IDTRANS_TABFORM, sBFormInit.majorID, 0);
|
||||
}
|
||||
|
||||
//now do status button
|
||||
sBFormInit2.pTip = NULL;
|
||||
|
||||
BufferID = (sBFormInit2.id - IDTRANS_STATSTART) * 2 + 1;
|
||||
ASSERT(BufferID < NUM_OBJECTBUFFERS, "BufferID > NUM_OBJECTBUFFERS");
|
||||
ClearObjectButtonBuffer(BufferID);
|
||||
RENDERBUTTON_INUSE(&ObjectBuffers[BufferID]);
|
||||
sBFormInit2.pUserData = &ObjectBuffers[BufferID];
|
||||
sBFormInit2.pDisplay = intDisplayStatusButton;
|
||||
|
||||
if (!widgAddForm(psWScreen, &sBFormInit2))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Update the init struct for the next buttons */
|
||||
sBFormInit.id += 1;
|
||||
ASSERT(sBFormInit.id < IDTRANS_END, "Too many Transporter buttons");
|
||||
|
||||
sBFormInit.x += OBJ_BUTWIDTH + OBJ_GAP;
|
||||
if (sBFormInit.x + OBJ_BUTWIDTH + OBJ_GAP > OBJ_WIDTH)
|
||||
{
|
||||
sBFormInit.x = OBJ_STARTX;
|
||||
sBFormInit.majorID += 1;
|
||||
}
|
||||
|
||||
sBFormInit2.id += 1;
|
||||
ASSERT(sBFormInit2.id < IDTRANS_STATEND, "Too many Transporter status buttons");
|
||||
|
||||
sBFormInit2.x += OBJ_BUTWIDTH + OBJ_GAP;
|
||||
if (sBFormInit2.x + OBJ_BUTWIDTH + OBJ_GAP > OBJ_WIDTH)
|
||||
{
|
||||
sBFormInit2.x = OBJ_STARTX;
|
||||
sBFormInit2.majorID += 1;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
WIDGET *buttonHolder = new WIDGET(transList);
|
||||
transList->addWidgetToLayout(buttonHolder);
|
||||
|
||||
IntStatusButton *statButton = new IntStatusButton(buttonHolder);
|
||||
statButton->id = nextStatButtonId;
|
||||
statButton->setGeometry(0, 0, OBJ_BUTWIDTH, OBJ_BUTHEIGHT);
|
||||
|
||||
IntObjectButton *objButton = new IntObjectButton(buttonHolder);
|
||||
objButton->id = nextObjButtonId;
|
||||
objButton->setGeometry(0, OBJ_STARTY, OBJ_BUTWIDTH, OBJ_BUTHEIGHT);
|
||||
|
||||
/* Set the tip and add the button */
|
||||
objButton->setTip(droidGetName(psDroid));
|
||||
objButton->setObject(psDroid);
|
||||
|
||||
//set the first Transporter to be the current one if not already set
|
||||
if (psCurrTransporter == nullptr)
|
||||
{
|
||||
psCurrTransporter = psDroid;
|
||||
}
|
||||
|
||||
/* if the current droid matches psCurrTransporter lock the button */
|
||||
if (psDroid == psCurrTransporter)
|
||||
{
|
||||
objButton->setState(WBUT_LOCK);
|
||||
transList->setCurrentPage(transList->pages() - 1);
|
||||
}
|
||||
|
||||
//now do status button
|
||||
statButton->setObject(nullptr);
|
||||
|
||||
/* Update the init struct for the next buttons */
|
||||
++nextObjButtonId;
|
||||
ASSERT(nextObjButtonId < IDTRANS_END, "Too many Transporter buttons");
|
||||
|
||||
++nextStatButtonId;
|
||||
ASSERT(nextStatButtonId < IDTRANS_STATEND, "Too many Transporter status buttons");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -629,100 +488,41 @@ bool intAddTransButtonForm(void)
|
|||
/* Add the Transporter Contents form */
|
||||
bool intAddTransContentsForm(void)
|
||||
{
|
||||
UDWORD i;
|
||||
SDWORD BufferID;
|
||||
DROID *psDroid, *psNext;
|
||||
WIDGET *contForm = widgGetFromID(psWScreen, IDTRANS_CONTENTFORM);
|
||||
|
||||
/* Add the contents form */
|
||||
W_FORMINIT sFormInit;
|
||||
sFormInit.formID = IDTRANS_CONTENTFORM;
|
||||
sFormInit.id = IDTRANS_CONTABFORM;
|
||||
sFormInit.style = WFORM_TABBED;
|
||||
sFormInit.width = TRANSCONT_WIDTH;
|
||||
sFormInit.height = TRANSCONT_HEIGHT;
|
||||
sFormInit.x = TRANSCONT_TABX;
|
||||
sFormInit.y = TRANSCONT_TABY;
|
||||
|
||||
sFormInit.majorPos = WFORM_TABTOP;
|
||||
sFormInit.minorPos = WFORM_TABNONE;
|
||||
sFormInit.majorSize = OBJ_TABWIDTH;
|
||||
sFormInit.majorOffset = OBJ_TABOFFSET;
|
||||
sFormInit.tabVertOffset = (OBJ_TABHEIGHT / 2);
|
||||
sFormInit.tabMajorThickness = OBJ_TABHEIGHT;
|
||||
|
||||
// TABFIXME: Looks like 10 units is max for this?
|
||||
sFormInit.numMajor = 1;
|
||||
|
||||
//set minor tabs to 1
|
||||
for (i = 0; i < sFormInit.numMajor; i++)
|
||||
{
|
||||
sFormInit.aNumMinors[i] = 1;
|
||||
}
|
||||
|
||||
sFormInit.pUserData = &StandardTab;
|
||||
sFormInit.pTabDisplay = intDisplayTab;
|
||||
|
||||
if (!widgAddForm(psWScreen, &sFormInit))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
IntListTabWidget *contList = new IntListTabWidget(contForm);
|
||||
contList->setChildSize(OBJ_BUTWIDTH, OBJ_BUTHEIGHT);
|
||||
contList->setChildSpacing(OBJ_GAP, OBJ_GAP);
|
||||
int contListWidth = OBJ_BUTWIDTH*2 + OBJ_GAP;
|
||||
contList->setGeometry((contForm->width() - contListWidth)/2, TRANSCONT_TABY, contListWidth, contForm->height() - TRANSCONT_TABY);
|
||||
|
||||
/* Add the transporter contents buttons */
|
||||
W_FORMINIT sBFormInit;
|
||||
sBFormInit.formID = IDTRANS_CONTABFORM;
|
||||
sBFormInit.id = IDTRANS_CONTSTART;
|
||||
sBFormInit.majorID = 0;
|
||||
sBFormInit.minorID = 0;
|
||||
sBFormInit.style = WFORM_CLICKABLE;
|
||||
sBFormInit.x = OBJ_STARTX;
|
||||
sBFormInit.y = OBJ_STARTY - OBJ_BUTHEIGHT - OBJ_GAP;
|
||||
sBFormInit.width = OBJ_BUTWIDTH;
|
||||
sBFormInit.height = OBJ_BUTHEIGHT;
|
||||
|
||||
ClearStatBuffers();
|
||||
int nextButtonId = IDTRANS_CONTSTART;
|
||||
|
||||
//add each button
|
||||
if (psCurrTransporter != NULL)
|
||||
if (psCurrTransporter == nullptr)
|
||||
{
|
||||
for (psDroid = psCurrTransporter->psGroup->psList; psDroid != NULL && psDroid !=
|
||||
psCurrTransporter; psDroid = psNext)
|
||||
return true;
|
||||
}
|
||||
|
||||
for (DROID *psDroid = psCurrTransporter->psGroup->psList; psDroid != nullptr && psDroid != psCurrTransporter; psDroid = psDroid->psGrpNext)
|
||||
{
|
||||
if (psDroid->selected)
|
||||
{
|
||||
psNext = psDroid->psGrpNext;
|
||||
if (psDroid->selected)
|
||||
{
|
||||
continue; // Droid is queued to be ejected from the transport, so don't display it.
|
||||
}
|
||||
/* Set the tip and add the button */
|
||||
sBFormInit.pTip = droidGetName(psDroid);
|
||||
BufferID = GetStatBuffer();
|
||||
ASSERT(BufferID >= 0, "Unable to acquire stat buffer.");
|
||||
RENDERBUTTON_INUSE(&StatBuffers[BufferID]);
|
||||
StatBuffers[BufferID].Data = (void *)psDroid;
|
||||
sBFormInit.pUserData = &StatBuffers[BufferID];
|
||||
sBFormInit.pDisplay = intDisplayTransportButton;
|
||||
|
||||
if (!widgAddForm(psWScreen, &sBFormInit))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Update the init struct for the next button */
|
||||
sBFormInit.id += 1;
|
||||
ASSERT(sBFormInit.id < IDTRANS_CONTEND, "Too many Transporter Droid buttons");
|
||||
|
||||
sBFormInit.x += OBJ_BUTWIDTH + OBJ_GAP;
|
||||
if (sBFormInit.x + OBJ_BUTWIDTH + OBJ_GAP > TRANSCONT_WIDTH)
|
||||
{
|
||||
sBFormInit.x = OBJ_STARTX;
|
||||
sBFormInit.y += OBJ_BUTHEIGHT + OBJ_GAP;
|
||||
}
|
||||
|
||||
if (sBFormInit.y + OBJ_BUTHEIGHT + OBJ_GAP > TRANSCONT_HEIGHT)
|
||||
{
|
||||
sBFormInit.y = OBJ_STARTY;
|
||||
sBFormInit.majorID += 1;
|
||||
}
|
||||
continue; // Droid is queued to be ejected from the transport, so don't display it.
|
||||
}
|
||||
|
||||
/* Set the tip and add the button */
|
||||
IntTransportButton *button = new IntTransportButton(contList);
|
||||
button->id = nextButtonId;
|
||||
button->setTip(droidGetName(psDroid));
|
||||
button->setObject(psDroid);
|
||||
contList->addWidgetToLayout(button);
|
||||
|
||||
/* Update the init struct for the next button */
|
||||
++nextButtonId;
|
||||
ASSERT(nextButtonId < IDTRANS_CONTEND, "Too many Transporter Droid buttons");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -730,12 +530,8 @@ bool intAddTransContentsForm(void)
|
|||
/* Add the Droids back at home form */
|
||||
bool intAddDroidsAvailForm(void)
|
||||
{
|
||||
UDWORD numButtons, i, butPerForm;
|
||||
SDWORD BufferID;
|
||||
DROID *psDroid;
|
||||
bool Animate = true;
|
||||
|
||||
// Is the form already up?
|
||||
bool Animate = true;
|
||||
if (widgGetFromID(psWScreen, IDTRANS_DROIDS) != NULL)
|
||||
{
|
||||
intRemoveTransDroidsAvailNoAnim();
|
||||
|
@ -747,32 +543,12 @@ bool intAddDroidsAvailForm(void)
|
|||
Animate = false;
|
||||
}
|
||||
|
||||
WIDGET *parent = psWScreen->psForm;
|
||||
|
||||
/* Add the droids available form */
|
||||
W_FORMINIT sFormInit;
|
||||
sFormInit.formID = 0;
|
||||
sFormInit.id = IDTRANS_DROIDS;
|
||||
sFormInit.style = WFORM_PLAIN;
|
||||
sFormInit.width = TRANSDROID_WIDTH;
|
||||
sFormInit.height = TRANSDROID_HEIGHT;
|
||||
sFormInit.x = (SWORD)TRANSDROID_X;
|
||||
sFormInit.y = (SWORD)TRANSDROID_Y;
|
||||
|
||||
// If the window was closed then do open animation.
|
||||
if (Animate)
|
||||
{
|
||||
sFormInit.pDisplay = intOpenPlainForm;
|
||||
sFormInit.disableChildren = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// otherwise just recreate it.
|
||||
sFormInit.pDisplay = intDisplayPlainForm;
|
||||
}
|
||||
|
||||
if (!widgAddForm(psWScreen, &sFormInit))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
IntFormAnimated *transDroids = new IntFormAnimated(parent, Animate); // Do not animate the opening, if the window was already open.
|
||||
transDroids->id = IDTRANS_DROIDS;
|
||||
transDroids->setGeometry(TRANSDROID_X, TRANSDROID_Y, TRANSDROID_WIDTH, TRANSDROID_HEIGHT);
|
||||
|
||||
/* Add the close button */
|
||||
W_BUTINIT sButInit;
|
||||
|
@ -791,82 +567,15 @@ bool intAddDroidsAvailForm(void)
|
|||
}
|
||||
|
||||
//now add the tabbed droids available form
|
||||
sFormInit = W_FORMINIT();
|
||||
sFormInit.formID = IDTRANS_DROIDS;
|
||||
sFormInit.id = IDTRANS_DROIDTAB;
|
||||
sFormInit.style = WFORM_TABBED;
|
||||
sFormInit.width = TRANSDROID_TABWIDTH;
|
||||
sFormInit.height = TRANSDROID_TABHEIGHT;
|
||||
sFormInit.x = TRANSDROID_TABX;
|
||||
sFormInit.y = TRANSDROID_TABY;
|
||||
|
||||
sFormInit.majorPos = WFORM_TABTOP;
|
||||
sFormInit.minorPos = WFORM_TABNONE;
|
||||
|
||||
sFormInit.majorSize = (OBJ_TABWIDTH / 2);
|
||||
|
||||
sFormInit.majorOffset = OBJ_TABOFFSET;
|
||||
sFormInit.tabVertOffset = (OBJ_TABHEIGHT / 2);
|
||||
sFormInit.tabMajorThickness = OBJ_TABHEIGHT;
|
||||
sFormInit.tabMajorGap = OBJ_TABOFFSET;
|
||||
|
||||
//calc num buttons
|
||||
numButtons = 0;
|
||||
//look through the list of droids that were built before the mission
|
||||
for (psDroid = mission.apsDroidLists[selectedPlayer]; psDroid; psDroid = psDroid->psNext)
|
||||
{
|
||||
//ignore any Transporters!
|
||||
if (psDroid->droidType != DROID_TRANSPORTER && psDroid->droidType != DROID_SUPERTRANSPORTER)
|
||||
{
|
||||
numButtons++;
|
||||
}
|
||||
//quit when reached max can cope with
|
||||
if (numButtons == MAX_DROIDS)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
butPerForm = ((TRANSDROID_TABWIDTH - OBJ_GAP) /
|
||||
(OBJ_BUTWIDTH + OBJ_GAP)) *
|
||||
((TRANSDROID_TABHEIGHT - OBJ_GAP) /
|
||||
(OBJ_BUTHEIGHT + OBJ_GAP));
|
||||
|
||||
sFormInit.numMajor = numForms(numButtons, butPerForm);
|
||||
if (sFormInit.numMajor > MAX_TAB_SMALL_SHOWN)
|
||||
{
|
||||
// we DO use smallTab icons here, so be safe and only display max # of
|
||||
// small sized tab icons. No scrolltabs here.
|
||||
sFormInit.numMajor = MAX_TAB_SMALL_SHOWN;
|
||||
}
|
||||
//set minor tabs to 1
|
||||
for (i = 0; i < sFormInit.numMajor; i++)
|
||||
{
|
||||
sFormInit.aNumMinors[i] = 1;
|
||||
}
|
||||
|
||||
sFormInit.pUserData = &SmallTab;
|
||||
|
||||
sFormInit.pTabDisplay = intDisplayTab;
|
||||
|
||||
if (!widgAddForm(psWScreen, &sFormInit))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
IntListTabWidget *droidList = new IntListTabWidget(transDroids);
|
||||
droidList->id = IDTRANS_DROIDTAB;
|
||||
droidList->setChildSize(OBJ_BUTWIDTH, OBJ_BUTHEIGHT);
|
||||
droidList->setChildSpacing(OBJ_GAP, OBJ_GAP);
|
||||
int droidListWidth = OBJ_BUTWIDTH*2 + OBJ_GAP;
|
||||
droidList->setGeometry((TRANSDROID_WIDTH - droidListWidth)/2, AVAIL_STARTY + 15, droidListWidth, TRANSDROID_HEIGHT - (AVAIL_STARTY + 15));
|
||||
|
||||
/* Add the droids available buttons */
|
||||
W_FORMINIT sBFormInit;
|
||||
sBFormInit.formID = IDTRANS_DROIDTAB;
|
||||
sBFormInit.id = IDTRANS_DROIDSTART;
|
||||
sBFormInit.majorID = 0;
|
||||
sBFormInit.minorID = 0;
|
||||
sBFormInit.style = WFORM_CLICKABLE;
|
||||
sBFormInit.x = OBJ_STARTX;
|
||||
sBFormInit.y = AVAIL_STARTY;
|
||||
sBFormInit.width = OBJ_BUTWIDTH;
|
||||
sBFormInit.height = OBJ_BUTHEIGHT;
|
||||
|
||||
ClearSystem0Buffers();
|
||||
int nextButtonId = IDTRANS_DROIDSTART;
|
||||
|
||||
/* Add the state of repair bar for each droid*/
|
||||
W_BARINIT sBarInit;
|
||||
|
@ -880,10 +589,10 @@ bool intAddDroidsAvailForm(void)
|
|||
sBarInit.sMinorCol = WZCOL_ACTION_PROGRESS_BAR_MINOR;
|
||||
|
||||
//add droids built before the mission
|
||||
for (psDroid = mission.apsDroidLists[selectedPlayer]; psDroid != NULL; psDroid = psDroid->psNext)
|
||||
for (DROID *psDroid = mission.apsDroidLists[selectedPlayer]; psDroid != nullptr; psDroid = psDroid->psNext)
|
||||
{
|
||||
//stop adding the buttons once MAX_DROIDS has been reached
|
||||
if (sBFormInit.id == (IDTRANS_DROIDSTART + MAX_DROIDS))
|
||||
//stop adding the buttons once IDTRANS_DROIDEND has been reached
|
||||
if (nextButtonId == IDTRANS_DROIDEND)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
@ -891,18 +600,11 @@ bool intAddDroidsAvailForm(void)
|
|||
if ((psDroid->droidType != DROID_TRANSPORTER && psDroid->droidType != DROID_SUPERTRANSPORTER))
|
||||
{
|
||||
/* Set the tip and add the button */
|
||||
sBFormInit.pTip = droidGetName(psDroid);
|
||||
BufferID = GetSystem0Buffer();
|
||||
ASSERT(BufferID >= 0, "Unable to acquire stat buffer.");
|
||||
RENDERBUTTON_INUSE(&System0Buffers[BufferID]);
|
||||
System0Buffers[BufferID].Data = (void *)psDroid;
|
||||
sBFormInit.pUserData = &System0Buffers[BufferID];
|
||||
sBFormInit.pDisplay = intDisplayTransportButton;
|
||||
|
||||
if (!widgAddForm(psWScreen, &sBFormInit))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
IntTransportButton *button = new IntTransportButton(droidList);
|
||||
button->id = nextButtonId;
|
||||
button->setTip(droidGetName(psDroid));
|
||||
button->setObject(psDroid);
|
||||
droidList->addWidgetToLayout(button);
|
||||
|
||||
//add bar to indicate stare of repair
|
||||
sBarInit.size = (UWORD) PERCENT(psDroid->body, psDroid->originalBody);
|
||||
|
@ -911,7 +613,7 @@ bool intAddDroidsAvailForm(void)
|
|||
sBarInit.size = 100;
|
||||
}
|
||||
|
||||
sBarInit.formID = sBFormInit.id;
|
||||
sBarInit.formID = nextButtonId;
|
||||
//sBarInit.iRange = TBAR_MAX_REPAIR;
|
||||
if (!widgAddBarGraph(psWScreen, &sBarInit))
|
||||
{
|
||||
|
@ -919,37 +621,16 @@ bool intAddDroidsAvailForm(void)
|
|||
}
|
||||
|
||||
/* Update the init struct for the next button */
|
||||
sBFormInit.id += 1;
|
||||
ASSERT(sBFormInit.id < IDTRANS_DROIDEND, "Too many Droids Built buttons");
|
||||
++nextButtonId;
|
||||
ASSERT(nextButtonId < IDTRANS_DROIDEND, "Too many Droids Built buttons");
|
||||
|
||||
sBFormInit.x += OBJ_BUTWIDTH + OBJ_GAP;
|
||||
if (sBFormInit.x + OBJ_BUTWIDTH + OBJ_GAP > TRANSDROID_TABWIDTH)
|
||||
{
|
||||
sBFormInit.x = OBJ_STARTX;
|
||||
sBFormInit.y += OBJ_BUTHEIGHT + OBJ_GAP;
|
||||
}
|
||||
|
||||
if (sBFormInit.y + OBJ_BUTHEIGHT + OBJ_GAP > TRANSDROID_TABHEIGHT)
|
||||
{
|
||||
sBFormInit.y = AVAIL_STARTY;
|
||||
sBFormInit.majorID += 1;
|
||||
}
|
||||
//and bar
|
||||
sBarInit.id += 1;
|
||||
}
|
||||
}
|
||||
|
||||
//reset which tab we were on
|
||||
if (objMajor > (UWORD)(sFormInit.numMajor - 1))
|
||||
{
|
||||
//set to last if have lost a tab
|
||||
widgSetTabs(psWScreen, IDTRANS_DROIDTAB, (UWORD)(sFormInit.numMajor - 1), objMinor);
|
||||
}
|
||||
else
|
||||
{
|
||||
//set to same tab we were on previously
|
||||
widgSetTabs(psWScreen, IDTRANS_DROIDTAB, objMajor, objMinor);
|
||||
}
|
||||
droidList->setCurrentPage(objMajor);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -994,7 +675,7 @@ bool transporterIsEmpty(const DROID *psTransporter)
|
|||
|| psTransporter->psGroup->psList == psTransporter);
|
||||
}
|
||||
|
||||
static void intSetTransCapacityLabel(char *Label)
|
||||
static void intSetTransCapacityLabel(QString &text)
|
||||
{
|
||||
UDWORD capacity = TRANSPORTER_CAPACITY;
|
||||
|
||||
|
@ -1005,8 +686,9 @@ static void intSetTransCapacityLabel(char *Label)
|
|||
//change round the way the remaining capacity is displayed - show 0/10 when empty now
|
||||
capacity = TRANSPORTER_CAPACITY - capacity;
|
||||
|
||||
Label[0] = (UBYTE)('0' + capacity / 10);
|
||||
Label[1] = (UBYTE)('0' + capacity % 10);
|
||||
char tmp[40];
|
||||
ssprintf(tmp, "%02u/10", capacity);
|
||||
text = QString::fromUtf8(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1089,38 +771,16 @@ static void _intProcessTransporter(UDWORD id)
|
|||
is called by intTransporterAddDroid()*/
|
||||
}
|
||||
}
|
||||
// Process form tab clicks.
|
||||
else if (id == IDTRANS_TABFORM)
|
||||
{
|
||||
//If tab clicked on Transporter screen then refresh rendered buttons.
|
||||
RefreshObjectButtons();
|
||||
RefreshTopicButtons();
|
||||
}
|
||||
else if (id == IDTRANS_CONTABFORM)
|
||||
{
|
||||
//If tab clicked on Transporter Contents screen then refresh rendered buttons.
|
||||
RefreshStatsButtons();
|
||||
}
|
||||
else if (id == IDTRANS_DROIDTAB)
|
||||
{
|
||||
//If tab clicked on Droids Available screen then refresh rendered buttons.
|
||||
RefreshSystem0Buttons();
|
||||
}
|
||||
}
|
||||
|
||||
/* Remove the Transporter widgets from the screen */
|
||||
void intRemoveTrans(void)
|
||||
{
|
||||
W_TABFORM *Form;
|
||||
|
||||
// Start the window close animation.
|
||||
Form = (W_TABFORM *)widgGetFromID(psWScreen, IDTRANS_FORM);
|
||||
if (Form)
|
||||
IntFormAnimated *form = (IntFormAnimated *)widgGetFromID(psWScreen, IDTRANS_FORM);
|
||||
if (form)
|
||||
{
|
||||
Form->display = intClosePlainForm;
|
||||
Form->disableChildren = true;
|
||||
Form->pUserData = NULL; // Used to signal when the close anim has finished.
|
||||
ClosingTrans = true;
|
||||
form->closeAnimateDelete();
|
||||
}
|
||||
|
||||
intRemoveTransContent();
|
||||
|
@ -1141,16 +801,11 @@ void intRemoveTransNoAnim(void)
|
|||
/* Remove the Transporter Content widgets from the screen */
|
||||
void intRemoveTransContent(void)
|
||||
{
|
||||
W_TABFORM *Form;
|
||||
|
||||
// Start the window close animation.
|
||||
Form = (W_TABFORM *)widgGetFromID(psWScreen, IDTRANS_CONTENTFORM);
|
||||
if (Form)
|
||||
IntFormAnimated *form = (IntFormAnimated *)widgGetFromID(psWScreen, IDTRANS_CONTENTFORM);
|
||||
if (form)
|
||||
{
|
||||
Form->display = intClosePlainForm;
|
||||
Form->disableChildren = true;
|
||||
Form->pUserData = NULL; // Used to signal when the close anim has finished.
|
||||
ClosingTransCont = true;
|
||||
form->closeAnimateDelete();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1164,31 +819,29 @@ void intRemoveTransContentNoAnim(void)
|
|||
/* Remove the Transporter Droids Avail widgets from the screen */
|
||||
void intRemoveTransDroidsAvail(void)
|
||||
{
|
||||
W_TABFORM *Form;
|
||||
|
||||
// Start the window close animation.
|
||||
Form = (W_TABFORM *)widgGetFromID(psWScreen, IDTRANS_DROIDS);
|
||||
if (Form)
|
||||
IntFormAnimated *form = (IntFormAnimated *)widgGetFromID(psWScreen, IDTRANS_DROIDS);
|
||||
if (form)
|
||||
{
|
||||
Form->display = intClosePlainForm;
|
||||
Form->disableChildren = true;
|
||||
Form->pUserData = NULL; // Used to signal when the close anim has finished.
|
||||
ClosingTransDroids = true;
|
||||
//remember which tab we were on
|
||||
widgGetTabs(psWScreen, IDTRANS_DROIDTAB, &objMajor, &objMinor);
|
||||
ListTabWidget *droidList = (ListTabWidget *)widgGetFromID(psWScreen, IDTRANS_DROIDTAB);
|
||||
objMajor = droidList->currentPage();
|
||||
form->closeAnimateDelete();
|
||||
}
|
||||
}
|
||||
|
||||
/* Remove the Transporter Droids Avail widgets from the screen w/o animation!*/
|
||||
void intRemoveTransDroidsAvailNoAnim(void)
|
||||
{
|
||||
if (widgGetFromID(psWScreen, IDTRANS_DROIDS) != NULL)
|
||||
IntFormAnimated *form = (IntFormAnimated *)widgGetFromID(psWScreen, IDTRANS_DROIDS);
|
||||
if (form != nullptr)
|
||||
{
|
||||
//remember which tab we were on
|
||||
widgGetTabs(psWScreen, IDTRANS_DROIDTAB, &objMajor, &objMinor);
|
||||
ListTabWidget *droidList = (ListTabWidget *)widgGetFromID(psWScreen, IDTRANS_DROIDTAB);
|
||||
objMajor = droidList->currentPage();
|
||||
|
||||
//remove main screen
|
||||
widgDelete(psWScreen, IDTRANS_DROIDS);
|
||||
delete form;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1589,14 +1242,14 @@ void processLaunchTransporter(void)
|
|||
psForm = (W_CLICKFORM *)widgGetFromID(psWScreen, IDTRANS_LAUNCH);
|
||||
if (psForm)
|
||||
{
|
||||
formSetClickState(psForm, WBUT_LOCK);
|
||||
psForm->setState(WBUT_LOCK);
|
||||
}
|
||||
|
||||
//disable the form so can't add any more droids into the transporter
|
||||
psForm = (W_CLICKFORM *)widgGetFromID(psWScreen, IDTRANTIMER_BUTTON);
|
||||
if (psForm)
|
||||
{
|
||||
formSetClickState(psForm, WBUT_LOCK);
|
||||
psForm->setState(WBUT_LOCK);
|
||||
}
|
||||
|
||||
launchTransporter(psCurrTransporter);
|
||||
|
@ -1624,10 +1277,8 @@ SDWORD bobTransporterHeight(void)
|
|||
/*causes one of the mission buttons (Launch Button or Mission Timer) to start flashing*/
|
||||
void flashMissionButton(UDWORD buttonID)
|
||||
{
|
||||
W_TABFORM *psForm;
|
||||
|
||||
//get the button from the id
|
||||
psForm = (W_TABFORM *)widgGetFromID(psWScreen, buttonID);
|
||||
WIDGET *psForm = widgGetFromID(psWScreen, buttonID);
|
||||
if (psForm)
|
||||
{
|
||||
switch (buttonID)
|
||||
|
@ -1649,10 +1300,8 @@ void flashMissionButton(UDWORD buttonID)
|
|||
/*stops one of the mission buttons (Launch Button or Mission Timer) flashing*/
|
||||
void stopMissionButtonFlash(UDWORD buttonID)
|
||||
{
|
||||
W_TABFORM *psForm;
|
||||
|
||||
//get the button from the id
|
||||
psForm = (W_TABFORM *)widgGetFromID(psWScreen, buttonID);
|
||||
WIDGET *psForm = widgGetFromID(psWScreen, buttonID);
|
||||
if (psForm)
|
||||
{
|
||||
switch (buttonID)
|
||||
|
@ -1692,7 +1341,7 @@ void resetTransporter()
|
|||
psForm = (W_CLICKFORM *)widgGetFromID(psWScreen, IDTRANS_LAUNCH);
|
||||
if (psForm)
|
||||
{
|
||||
formSetClickState(psForm, 0);
|
||||
psForm->setState(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue