widget: Use QString internally.

Previously, some strings were stored in fixed length static arrays, and others were stored as pointers to the
original (uncopied) data.
master
Cyp 2013-02-12 00:08:37 +01:00
parent 57b5b680e0
commit 84e3461ffc
22 changed files with 168 additions and 160 deletions

View File

@ -58,7 +58,7 @@ W_BARGRAPH::W_BARGRAPH(W_BARINIT const *init)
, majorCol(init->sCol) , majorCol(init->sCol)
, minorCol(init->sMinorCol) , minorCol(init->sMinorCol)
, textCol(WZCOL_BLACK) , textCol(WZCOL_BLACK)
, pTip(init->pTip) , pTip(QString::fromUtf8(init->pTip))
{ {
/* Set the display function */ /* Set the display function */
if (display == NULL) if (display == NULL)
@ -194,7 +194,7 @@ void widgSetMinorBarSize(W_SCREEN *psScreen, UDWORD id, UDWORD iValue)
/* Respond to a mouse moving over a barGraph */ /* Respond to a mouse moving over a barGraph */
void W_BARGRAPH::highlight(W_CONTEXT *psContext) void W_BARGRAPH::highlight(W_CONTEXT *psContext)
{ {
if (pTip) if (!pTip.isEmpty())
{ {
tipStart(this, pTip, psContext->psScreen->TipFontID, tipStart(this, pTip, psContext->psScreen->TipFontID,
psContext->psForm->aColours, psContext->psForm->aColours,

View File

@ -45,7 +45,7 @@ struct W_BARGRAPH : public WIDGET
PIELIGHT majorCol; // Colour for the major bar PIELIGHT majorCol; // Colour for the major bar
PIELIGHT minorCol; // Colour for the minor bar PIELIGHT minorCol; // Colour for the minor bar
PIELIGHT textCol; // Colour for the text on the 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. QString text; // Text on the bar.
}; };

View File

@ -46,8 +46,8 @@ W_BUTINIT::W_BUTINIT()
W_BUTTON::W_BUTTON(W_BUTINIT const *init) W_BUTTON::W_BUTTON(W_BUTINIT const *init)
: WIDGET(init, WIDG_BUTTON) : WIDGET(init, WIDG_BUTTON)
, pText(init->pText) , pText(QString::fromUtf8(init->pText))
, pTip(init->pTip) , pTip(QString::fromUtf8(init->pTip))
, HilightAudioID(WidgGetHilightAudioID()) , HilightAudioID(WidgGetHilightAudioID())
, ClickedAudioID(WidgGetClickedAudioID()) , ClickedAudioID(WidgGetClickedAudioID())
, AudioCallback(WidgGetAudioCallback()) , AudioCallback(WidgGetAudioCallback())
@ -157,16 +157,15 @@ void W_BUTTON::setState(unsigned newState)
/* Run a button widget */ /* Run a button widget */
void W_BUTTON::run(W_CONTEXT *) void W_BUTTON::run(W_CONTEXT *)
{ {
W_BUTTON *psButton = this; if (state & WBUTS_FLASH)
if (psButton->state & WBUTS_FLASH)
{ {
if (((realTime / 250) % 2) == 0) if (((realTime / 250) % 2) == 0)
{ {
psButton->state &= ~WBUTS_FLASHON; state &= ~WBUTS_FLASHON;
} }
else else
{ {
psButton->state |= WBUTS_FLASHON; state |= WBUTS_FLASHON;
} }
} }
} }
@ -175,28 +174,27 @@ void W_BUTTON::run(W_CONTEXT *)
/* Respond to a mouse click */ /* Respond to a mouse click */
void W_BUTTON::clicked(W_CONTEXT *, WIDGET_KEY key) 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 */ /* Can't click a button if it is disabled or locked down */
if (!(psWidget->state & (WBUTS_GREY | WBUTS_LOCKED))) if (!(state & (WBUTS_GREY | WBUTS_LOCKED)))
{ {
// Check this is the correct key // Check this is the correct key
if ((!(psWidget->style & WBUT_NOPRIMARY) && key == WKEY_PRIMARY) || if ((!(style & WBUT_NOPRIMARY) && key == WKEY_PRIMARY) ||
((psWidget->style & WBUT_SECONDARY) && key == WKEY_SECONDARY)) ((style & WBUT_SECONDARY) && key == WKEY_SECONDARY))
{ {
if (psWidget->AudioCallback) if (AudioCallback)
{ {
psWidget->AudioCallback(psWidget->ClickedAudioID); AudioCallback(ClickedAudioID);
} }
psWidget->state &= ~WBUTS_FLASH; // Stop it flashing state &= ~WBUTS_FLASH; // Stop it flashing
psWidget->state &= ~WBUTS_FLASHON; state &= ~WBUTS_FLASHON;
psWidget->state |= WBUTS_DOWN; state |= WBUTS_DOWN;
} }
} }
/* Kill the tip if there is one */ /* Kill the tip if there is one */
if (psWidget->pTip) if (!pTip.isEmpty())
{ {
tipStop((WIDGET *)psWidget); tipStop(this);
} }
} }
@ -204,15 +202,14 @@ void W_BUTTON::clicked(W_CONTEXT *, WIDGET_KEY key)
void W_BUTTON::released(W_CONTEXT *psContext, WIDGET_KEY key) void W_BUTTON::released(W_CONTEXT *psContext, WIDGET_KEY key)
{ {
W_SCREEN *psScreen = psContext->psScreen; W_SCREEN *psScreen = psContext->psScreen;
W_BUTTON *psWidget = this; if (state & WBUTS_DOWN)
if (psWidget->state & WBUTS_DOWN)
{ {
// Check this is the correct key // Check this is the correct key
if ((!(psWidget->style & WBUT_NOPRIMARY) && key == WKEY_PRIMARY) || if ((!(style & WBUT_NOPRIMARY) && key == WKEY_PRIMARY) ||
((psWidget->style & WBUT_SECONDARY) && key == WKEY_SECONDARY)) ((style & WBUT_SECONDARY) && key == WKEY_SECONDARY))
{ {
widgSetReturn(psScreen, (WIDGET *)psWidget); widgSetReturn(psScreen, this);
psWidget->state &= ~WBUTS_DOWN; state &= ~WBUTS_DOWN;
} }
} }
} }
@ -221,21 +218,20 @@ void W_BUTTON::released(W_CONTEXT *psContext, WIDGET_KEY key)
/* Respond to a mouse moving over a button */ /* Respond to a mouse moving over a button */
void W_BUTTON::highlight(W_CONTEXT *psContext) void W_BUTTON::highlight(W_CONTEXT *psContext)
{ {
W_BUTTON *psWidget = this; state |= WBUTS_HILITE;
psWidget->state |= WBUTS_HILITE;
if (psWidget->AudioCallback) if (AudioCallback)
{ {
psWidget->AudioCallback(psWidget->HilightAudioID); AudioCallback(HilightAudioID);
} }
/* If there is a tip string start the tool tip */ /* If there is a tip string start the tool tip */
if (psWidget->pTip) if (!pTip.isEmpty())
{ {
tipStart((WIDGET *)psWidget, psWidget->pTip, psContext->psScreen->TipFontID, tipStart(this, pTip, psContext->psScreen->TipFontID,
psContext->psForm->aColours, psContext->psForm->aColours,
psWidget->x + psContext->xOffset, psWidget->y + psContext->yOffset, x + psContext->xOffset, y + psContext->yOffset,
psWidget->width, psWidget->height); width, height);
} }
} }
@ -243,11 +239,10 @@ void W_BUTTON::highlight(W_CONTEXT *psContext)
/* Respond to the mouse moving off a button */ /* Respond to the mouse moving off a button */
void W_BUTTON::highlightLost(W_CONTEXT *) void W_BUTTON::highlightLost(W_CONTEXT *)
{ {
W_BUTTON *psWidget = this; state &= ~(WBUTS_DOWN | WBUTS_HILITE);
psWidget->state &= ~(WBUTS_DOWN | WBUTS_HILITE); if (!pTip.isEmpty())
if (psWidget->pTip)
{ {
tipStop((WIDGET *)psWidget); tipStop(this);
} }
} }
@ -271,16 +266,20 @@ void buttonDisplay(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *p
x1 = x0 + psButton->width; x1 = x0 + psButton->width;
y1 = y0 + psButton->height; y1 = y0 + psButton->height;
bool haveText = !psButton->pText.isEmpty();
QByteArray textBytes = psButton->pText.toUtf8();
char const *textData = textBytes.constData();
if (psButton->state & (WBUTS_DOWN | WBUTS_LOCKED | WBUTS_CLICKLOCK)) if (psButton->state & (WBUTS_DOWN | WBUTS_LOCKED | WBUTS_CLICKLOCK))
{ {
/* Display the button down */ /* Display the button down */
iV_ShadowBox(x0, y0, x1, y1, 0, pColours[WCOL_LIGHT], pColours[WCOL_DARK], pColours[WCOL_BKGRND]); iV_ShadowBox(x0, y0, x1, y1, 0, pColours[WCOL_LIGHT], pColours[WCOL_DARK], pColours[WCOL_BKGRND]);
if (psButton->pText) if (haveText)
{ {
iV_SetFont(psButton->FontID); iV_SetFont(psButton->FontID);
iV_SetTextColour(pColours[WCOL_TEXT]); iV_SetTextColour(pColours[WCOL_TEXT]);
fw = iV_GetTextWidth(psButton->pText); fw = iV_GetTextWidth(textData);
if (psButton->style & WBUT_NOCLICKMOVE) if (psButton->style & WBUT_NOCLICKMOVE)
{ {
fx = x0 + (psButton->width - fw) / 2 + 1; fx = x0 + (psButton->width - fw) / 2 + 1;
@ -291,7 +290,7 @@ void buttonDisplay(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *p
fx = x0 + (psButton->width - fw) / 2; fx = x0 + (psButton->width - fw) / 2;
fy = y0 + (psButton->height - iV_GetTextLineSize()) / 2 - iV_GetTextAboveBase(); fy = y0 + (psButton->height - iV_GetTextLineSize()) / 2 - iV_GetTextAboveBase();
} }
iV_DrawText(psButton->pText, fx, fy); iV_DrawText(textData, fx, fy);
} }
if (psButton->state & WBUTS_HILITE) if (psButton->state & WBUTS_HILITE)
@ -305,16 +304,16 @@ void buttonDisplay(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *p
/* Display the disabled button */ /* Display the disabled button */
iV_ShadowBox(x0, y0, x1, y1, 0, pColours[WCOL_LIGHT], pColours[WCOL_LIGHT], pColours[WCOL_BKGRND]); iV_ShadowBox(x0, y0, x1, y1, 0, pColours[WCOL_LIGHT], pColours[WCOL_LIGHT], pColours[WCOL_BKGRND]);
if (psButton->pText) if (haveText)
{ {
iV_SetFont(psButton->FontID); iV_SetFont(psButton->FontID);
fw = iV_GetTextWidth(psButton->pText); fw = iV_GetTextWidth(textData);
fx = x0 + (psButton->width - fw) / 2; fx = x0 + (psButton->width - fw) / 2;
fy = y0 + (psButton->height - iV_GetTextLineSize()) / 2 - iV_GetTextAboveBase(); fy = y0 + (psButton->height - iV_GetTextLineSize()) / 2 - iV_GetTextAboveBase();
iV_SetTextColour(pColours[WCOL_LIGHT]); iV_SetTextColour(pColours[WCOL_LIGHT]);
iV_DrawText(psButton->pText, fx + 1, fy + 1); iV_DrawText(textData, fx + 1, fy + 1);
iV_SetTextColour(pColours[WCOL_DISABLE]); iV_SetTextColour(pColours[WCOL_DISABLE]);
iV_DrawText(psButton->pText, fx, fy); iV_DrawText(textData, fx, fy);
} }
if (psButton->state & WBUTS_HILITE) if (psButton->state & WBUTS_HILITE)
@ -328,14 +327,14 @@ void buttonDisplay(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *p
/* Display the button up */ /* Display the button up */
iV_ShadowBox(x0, y0, x1, y1, 0, pColours[WCOL_LIGHT], pColours[WCOL_DARK], pColours[WCOL_BKGRND]); iV_ShadowBox(x0, y0, x1, y1, 0, pColours[WCOL_LIGHT], pColours[WCOL_DARK], pColours[WCOL_BKGRND]);
if (psButton->pText) if (haveText)
{ {
iV_SetFont(psButton->FontID); iV_SetFont(psButton->FontID);
iV_SetTextColour(pColours[WCOL_TEXT]); iV_SetTextColour(pColours[WCOL_TEXT]);
fw = iV_GetTextWidth(psButton->pText); fw = iV_GetTextWidth(textData);
fx = x0 + (psButton->width - fw) / 2; fx = x0 + (psButton->width - fw) / 2;
fy = y0 + (psButton->height - iV_GetTextLineSize()) / 2 - iV_GetTextAboveBase(); fy = y0 + (psButton->height - iV_GetTextLineSize()) / 2 - iV_GetTextAboveBase();
iV_DrawText(psButton->pText, fx, fy); iV_DrawText(textData, fx, fy);
} }
if (psButton->state & WBUTS_HILITE) if (psButton->state & WBUTS_HILITE)

View File

@ -54,8 +54,8 @@ struct W_BUTTON : public WIDGET
void setFlash(bool enable); void setFlash(bool enable);
UDWORD state; // The current button state UDWORD state; // The current button state
const char *pText; // The text for the button QString pText; // The text for the button
const char *pTip; // The tool tip for the button QString pTip; // The tool tip for the button
SWORD HilightAudioID; // Audio ID for form clicked sound SWORD HilightAudioID; // Audio ID for form clicked sound
SWORD ClickedAudioID; // Audio ID for form hilighted sound SWORD ClickedAudioID; // Audio ID for form hilighted sound
WIDGET_AUDIOCALLBACK AudioCallback; // Pointer to audio callback function WIDGET_AUDIOCALLBACK AudioCallback; // Pointer to audio callback function

View File

@ -129,7 +129,7 @@ static void formFreePlain(W_FORM *psWidget)
W_CLICKFORM::W_CLICKFORM(W_FORMINIT const *init) W_CLICKFORM::W_CLICKFORM(W_FORMINIT const *init)
: W_FORM(init) : W_FORM(init)
, state(WCLICK_NORMAL) , state(WCLICK_NORMAL)
, pTip(init->pTip) , pTip(QString::fromUtf8(init->pTip))
, HilightAudioID(WidgGetHilightAudioID()) , HilightAudioID(WidgGetHilightAudioID())
, ClickedAudioID(WidgGetClickedAudioID()) , ClickedAudioID(WidgGetClickedAudioID())
, AudioCallback(WidgGetAudioCallback()) , AudioCallback(WidgGetAudioCallback())
@ -167,6 +167,17 @@ static void formFreeClickable(W_CLICKFORM *psWidget)
delete psWidget; delete psWidget;
} }
W_MINORTAB::W_MINORTAB()
: psWidgets(NULL)
{
}
W_MAJORTAB::W_MAJORTAB()
: lastMinor(0)
, numMinor(0)
{
}
W_TABFORM::W_TABFORM(W_FORMINIT const *init) W_TABFORM::W_TABFORM(W_FORMINIT const *init)
: W_FORM(init) : W_FORM(init)
@ -189,8 +200,6 @@ W_TABFORM::W_TABFORM(W_FORMINIT const *init)
, numButtons(init->numButtons) , numButtons(init->numButtons)
, pTabDisplay(init->pTabDisplay) , pTabDisplay(init->pTabDisplay)
{ {
memset(asMajor, 0, sizeof(asMajor));
/* Allocate the memory for tool tips and copy them in */ /* Allocate the memory for tool tips and copy them in */
/* Set up the tab data. /* Set up the tab data.
* All widget pointers have been zeroed by the memset above. * All widget pointers have been zeroed by the memset above.
@ -199,14 +208,14 @@ W_TABFORM::W_TABFORM(W_FORMINIT const *init)
for (unsigned major = 0; major < init->numMajor; ++major) for (unsigned major = 0; major < init->numMajor; ++major)
{ {
/* Check for a tip for the major tab */ /* Check for a tip for the major tab */
asMajor[major].pTip = init->apMajorTips[major]; asMajor[major].pTip = QString::fromUtf8(init->apMajorTips[major]);
asMajor[major].lastMinor = 0; asMajor[major].lastMinor = 0;
/* Check for tips for the minor tab */ /* Check for tips for the minor tab */
asMajor[major].numMinor = init->aNumMinors[major]; asMajor[major].numMinor = init->aNumMinors[major];
for (unsigned minor = 0; minor < init->aNumMinors[major]; ++minor) for (unsigned minor = 0; minor < init->aNumMinors[major]; ++minor)
{ {
asMajor[major].asMinor[minor].pTip = init->apMinorTips[major][minor]; asMajor[major].asMinor[minor].pTip = QString::fromUtf8(init->apMinorTips[major][minor]);
} }
} }
@ -988,7 +997,7 @@ void W_TABFORM::run(W_CONTEXT *psContext)
{ {
// Got a new tab - start the tool tip if there is one. // Got a new tab - start the tool tip if there is one.
tabHiLite = (UWORD)sTabPos.index; tabHiLite = (UWORD)sTabPos.index;
char *pTip; QString pTip;
if (sTabPos.index >= numMajor) if (sTabPos.index >= numMajor)
{ {
pTip = asMajor[majorT].asMinor[sTabPos.index - numMajor].pTip; pTip = asMajor[majorT].asMinor[sTabPos.index - numMajor].pTip;
@ -997,7 +1006,7 @@ void W_TABFORM::run(W_CONTEXT *psContext)
{ {
pTip = asMajor[sTabPos.index].pTip; pTip = asMajor[sTabPos.index].pTip;
} }
if (pTip) if (!pTip.isEmpty())
{ {
// Got a tip - start it off. // Got a tip - start it off.
tipStart(this, pTip, psContext->psScreen->TipFontID, aColours, sTabPos.x + psContext->xOffset, sTabPos.y + psContext->yOffset, sTabPos.width, sTabPos.height); tipStart(this, pTip, psContext->psScreen->TipFontID, aColours, sTabPos.x + psContext->xOffset, sTabPos.y + psContext->yOffset, sTabPos.width, sTabPos.height);
@ -1123,7 +1132,7 @@ void W_CLICKFORM::highlight(W_CONTEXT *psContext)
state |= WCLICK_HILITE; state |= WCLICK_HILITE;
// If there is a tip string start the tool tip. // 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, psContext->psScreen->TipFontID, psContext->psForm->aColours, x + psContext->xOffset, y + psContext->yOffset, width, height);
} }

View File

@ -47,19 +47,23 @@ struct W_FORM : public WIDGET
/* Information for a minor tab */ /* Information for a minor tab */
struct W_MINORTAB struct W_MINORTAB
{ {
W_MINORTAB();
/* Graphics data for the tab will go here */ /* Graphics data for the tab will go here */
WIDGET *psWidgets; // Widgets on the tab WIDGET *psWidgets; // Widgets on the tab
char *pTip; // Tool tip QString pTip; // Tool tip
}; };
/* Information for a major tab */ /* Information for a major tab */
struct W_MAJORTAB struct W_MAJORTAB
{ {
W_MAJORTAB();
/* Graphics data for the tab will go here */ /* Graphics data for the tab will go here */
UWORD lastMinor; // Store which was the last selected minor tab UWORD lastMinor; // Store which was the last selected minor tab
UWORD numMinor; UWORD numMinor;
W_MINORTAB asMinor[WFORM_MAXMINOR]; // Minor tab information W_MINORTAB asMinor[WFORM_MAXMINOR]; // Minor tab information
char *pTip; QString pTip;
}; };
/* The tabbed form data structure */ /* The tabbed form data structure */
@ -124,7 +128,7 @@ struct W_CLICKFORM : public W_FORM
void setFlash(bool enable); void setFlash(bool enable);
UDWORD state; // Button state of the form 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 HilightAudioID; // Audio ID for form clicked sound
SWORD ClickedAudioID; // Audio ID for form hilighted sound SWORD ClickedAudioID; // Audio ID for form hilighted sound
WIDGET_AUDIOCALLBACK AudioCallback; // Pointer to audio callback function WIDGET_AUDIOCALLBACK AudioCallback; // Pointer to audio callback function

View File

@ -38,19 +38,14 @@ W_LABINIT::W_LABINIT()
W_LABEL::W_LABEL(W_LABINIT const *init) W_LABEL::W_LABEL(W_LABINIT const *init)
: WIDGET(init, WIDG_LABEL) : WIDGET(init, WIDG_LABEL)
, aText(QString::fromUtf8(init->pText))
, FontID(init->FontID) , FontID(init->FontID)
, pTip(init->pTip) , pTip(QString::fromUtf8(init->pTip))
{ {
if (display == NULL) if (display == NULL)
{ {
display = labelDisplay; display = labelDisplay;
} }
aText[0] = '\0';
if (init->pText)
{
sstrcpy(aText, init->pText);
}
} }
@ -100,14 +95,15 @@ void labelDisplay(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pC
iV_SetFont(FontID); iV_SetFont(FontID);
iV_SetTextColour(pColours[WCOL_TEXT]); iV_SetTextColour(pColours[WCOL_TEXT]);
QByteArray text = psLabel->aText.toUtf8();
if (psLabel->style & WLAB_ALIGNCENTRE) if (psLabel->style & WLAB_ALIGNCENTRE)
{ {
fw = iV_GetTextWidth(psLabel->aText); fw = iV_GetTextWidth(text.constData());
fx = xOffset + psLabel->x + (psLabel->width - fw) / 2; fx = xOffset + psLabel->x + (psLabel->width - fw) / 2;
} }
else if (psLabel->style & WLAB_ALIGNRIGHT) else if (psLabel->style & WLAB_ALIGNRIGHT)
{ {
fw = iV_GetTextWidth(psLabel->aText); fw = iV_GetTextWidth(text.constData());
fx = xOffset + psLabel->x + psLabel->width - fw; fx = xOffset + psLabel->x + psLabel->width - fw;
} }
else else
@ -115,14 +111,14 @@ void labelDisplay(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pC
fx = xOffset + psLabel->x; fx = xOffset + psLabel->x;
} }
fy = yOffset + psLabel->y + (psLabel->height - iV_GetTextLineSize()) / 2 - iV_GetTextAboveBase(); fy = yOffset + psLabel->y + (psLabel->height - iV_GetTextLineSize()) / 2 - iV_GetTextAboveBase();
iV_DrawText(psLabel->aText, fx, fy); iV_DrawText(text.constData(), fx, fy);
} }
/* Respond to a mouse moving over a label */ /* Respond to a mouse moving over a label */
void W_LABEL::highlight(W_CONTEXT *psContext) void W_LABEL::highlight(W_CONTEXT *psContext)
{ {
/* If there is a tip string start the tool tip */ /* If there is a tip string start the tool tip */
if (pTip) if (!pTip.isEmpty())
{ {
tipStart(this, pTip, psContext->psScreen->TipFontID, tipStart(this, pTip, psContext->psScreen->TipFontID,
psContext->psForm->aColours, psContext->psForm->aColours,
@ -135,7 +131,7 @@ void W_LABEL::highlight(W_CONTEXT *psContext)
/* Respond to the mouse moving off a label */ /* Respond to the mouse moving off a label */
void W_LABEL::highlightLost(W_CONTEXT *) void W_LABEL::highlightLost(W_CONTEXT *)
{ {
if (pTip) if (!pTip.isEmpty())
{ {
tipStop(this); tipStop(this);
} }

View File

@ -36,9 +36,9 @@ struct W_LABEL : public WIDGET
void highlight(W_CONTEXT *psContext); void highlight(W_CONTEXT *psContext);
void highlightLost(W_CONTEXT *); void highlightLost(W_CONTEXT *);
char aText[WIDG_MAXSTR]; // Text on the label QString aText; // Text on the label
enum iV_fonts FontID; iV_fonts FontID;
const char *pTip; // The tool tip for the button QString pTip; // The tool tip for the button
}; };
/* Create a button widget data structure */ /* Create a button widget data structure */

View File

@ -47,7 +47,7 @@ W_SLIDER::W_SLIDER(W_SLDINIT const *init)
, orientation(init->orientation) , orientation(init->orientation)
, numStops(init->numStops) , numStops(init->numStops)
, barSize(init->barSize) , barSize(init->barSize)
, pTip(init->pTip) , pTip(QString::fromUtf8(init->pTip))
{ {
if (display == NULL) if (display == NULL)
{ {

View File

@ -47,7 +47,7 @@ struct W_SLIDER : public WIDGET
UWORD barSize; // Thickness of slider bar UWORD barSize; // Thickness of slider bar
UWORD pos; // Current stop position of the slider UWORD pos; // Current stop position of the slider
UWORD state; // Slider state UWORD state; // Slider state
const char *pTip; // Tool tip QString pTip; // Tool tip
}; };
/* Create a slider widget data structure */ /* Create a slider widget data structure */

View File

@ -55,7 +55,7 @@ static SDWORD mx, my; // Last mouse coords
static SDWORD wx, wy, ww, wh; // Position and size of button to place tip by 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 tx, ty, tw, th; // Position and size of the tip box
static SDWORD fx, fy; // Position of the text static SDWORD fx, fy; // Position of the text
static const char *pTip; // Tip text static QString pTip; // Tip text
static PIELIGHT *pColours; // The colours for the tool tip static PIELIGHT *pColours; // The colours for the tool tip
static WIDGET *psWidget; // The button the tip is for static WIDGET *psWidget; // The button the tip is for
static enum iV_fonts FontID = font_regular; // ID for the Ivis Font. static enum iV_fonts FontID = font_regular; // ID for the Ivis Font.
@ -85,8 +85,7 @@ void widgSetTipColour(PIELIGHT colour)
* x,y,width,height - specify the position of the button to place the * x,y,width,height - specify the position of the button to place the
* tip by. * tip by.
*/ */
void tipStart(WIDGET *psSource, const char *pNewTip, enum iV_fonts NewFontID, void tipStart(WIDGET *psSource, QString pNewTip, iV_fonts NewFontID, PIELIGHT *pNewColours, int x, int y, int width, int height)
PIELIGHT *pNewColours, SDWORD x, SDWORD y, UDWORD width, UDWORD height)
{ {
ASSERT(psSource != NULL, ASSERT(psSource != NULL,
"tipStart: Invalid widget pointer"); "tipStart: Invalid widget pointer");
@ -152,7 +151,7 @@ void tipDisplay(void)
topGap = TIP_VGAP; topGap = TIP_VGAP;
iV_SetFont(FontID); iV_SetFont(FontID);
fw = iV_GetTextWidth(pTip); fw = iV_GetTextWidth(pTip.toUtf8().constData());
tw = fw + TIP_HGAP * 2; tw = fw + TIP_HGAP * 2;
th = topGap * 2 + iV_GetTextLineSize() + iV_GetTextBelowBase(); th = topGap * 2 + iV_GetTextLineSize() + iV_GetTextBelowBase();
@ -209,7 +208,7 @@ void tipDisplay(void)
iV_SetFont(FontID); iV_SetFont(FontID);
iV_SetTextColour(TipColour); iV_SetTextColour(TipColour);
iV_DrawText(pTip, fx, fy); iV_DrawText(pTip.toUtf8().constData(), fx, fy);
break; break;
default: default:

View File

@ -41,8 +41,7 @@ extern void tipInitialise(void);
* x,y,width,height - specify the position of the button to place the * x,y,width,height - specify the position of the button to place the
* tip by. * tip by.
*/ */
extern void tipStart(WIDGET *psSource, const char *pTip, enum iV_fonts NewFontID, void tipStart(WIDGET *psSource, QString pTip, iV_fonts NewFontID, PIELIGHT *pColours, int x, int y, int width, int height);
PIELIGHT *pColours, SDWORD x, SDWORD y, UDWORD width, UDWORD height);
/* Stop a tool tip (e.g. if the hilite is lost on a button). /* 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. * psSource should be the same as the widget that started the tip.

View File

@ -1051,17 +1051,10 @@ const char *widgGetString(W_SCREEN *psScreen, UDWORD id)
aStringRetBuffer[0] = '\0'; aStringRetBuffer[0] = '\0';
break; break;
case WIDG_LABEL: case WIDG_LABEL:
sstrcpy(aStringRetBuffer, ((W_LABEL *)psWidget)->aText); sstrcpy(aStringRetBuffer, ((W_LABEL *)psWidget)->aText.toUtf8().constData());
break; break;
case WIDG_BUTTON: case WIDG_BUTTON:
if (((W_BUTTON *)psWidget)->pText) sstrcpy(aStringRetBuffer, ((W_BUTTON *)psWidget)->pText.toUtf8().constData());
{
sstrcpy(aStringRetBuffer, ((W_BUTTON *)psWidget)->pText);
}
else
{
aStringRetBuffer[0] = '\0';
}
break; break;
case WIDG_EDITBOX: case WIDG_EDITBOX:
{ {
@ -1115,11 +1108,11 @@ void widgSetString(W_SCREEN *psScreen, UDWORD id, const char *pText)
break; break;
case WIDG_LABEL: case WIDG_LABEL:
sstrcpy(((W_LABEL *)psWidget)->aText, pText); ((W_LABEL *)psWidget)->aText = QString::fromUtf8(pText);
break; break;
case WIDG_BUTTON: case WIDG_BUTTON:
((W_BUTTON *)psWidget)->pText = pText; ((W_BUTTON *)psWidget)->pText = QString::fromUtf8(pText);
break; break;
case WIDG_EDITBOX: case WIDG_EDITBOX:

View File

@ -135,9 +135,9 @@ static void displayLoadSlot(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ
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_SetFont(font_regular); // font
iV_SetTextColour(WZCOL_FORM_TEXT); iV_SetTextColour(WZCOL_FORM_TEXT);
@ -364,7 +364,7 @@ bool runChallenges(void)
// clicked a load entry // clicked a load entry
if (id >= CHALLENGE_ENTRY_START && id <= CHALLENGE_ENTRY_END) 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); sstrcpy(sRequestResult, (const char *)((W_BUTTON *)widgGetFromID(psRequestScreen, id))->pUserData);
} }

View File

@ -1612,7 +1612,7 @@ static void displayText(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DEC
psLab = (W_LABEL *)psWidget; psLab = (W_LABEL *)psWidget;
iV_SetFont(psLab->FontID); iV_SetFont(psLab->FontID);
fw = iV_GetTextWidth(psLab->aText); fw = iV_GetTextWidth(psLab->aText.toUtf8().constData());
fy = yOffset + psWidget->y; fy = yOffset + psWidget->y;
if (psWidget->style & WLAB_ALIGNCENTRE) //check for centering, calculate offset. if (psWidget->style & WLAB_ALIGNCENTRE) //check for centering, calculate offset.
@ -1625,7 +1625,7 @@ static void displayText(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DEC
} }
iV_SetTextColour(WZCOL_TEXT_BRIGHT); iV_SetTextColour(WZCOL_TEXT_BRIGHT);
iV_DrawText( psLab->aText, fx, fy); iV_DrawText(psLab->aText.toUtf8().constData(), fx, fy);
return; return;
} }
@ -1642,12 +1642,12 @@ static void displayTextAt270(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, W
iV_SetFont(font_large); iV_SetFont(font_large);
fx = xOffset + psWidget->x; fx = xOffset + psWidget->x;
fy = yOffset + psWidget->y + iV_GetTextWidth(psLab->aText) ; fy = yOffset + psWidget->y + iV_GetTextWidth(psLab->aText.toUtf8().constData());
iV_SetTextColour(WZCOL_GREY); 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_SetTextColour(WZCOL_TEXT_BRIGHT);
iV_DrawTextRotated(psLab->aText, fx, fy, 270.f); iV_DrawTextRotated(psLab->aText.toUtf8().constData(), fx, fy, 270.f);
} }
// //////////////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////////////////
@ -1667,7 +1667,7 @@ void displayTextOption(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL
hilight = true; hilight = true;
} }
fw = iV_GetTextWidth(psBut->pText); fw = iV_GetTextWidth(psBut->pText.toUtf8().constData());
fy = yOffset + psWidget->y + (psWidget->height - iV_GetTextLineSize())/2 - iV_GetTextAboveBase(); fy = yOffset + psWidget->y + (psWidget->height - iV_GetTextLineSize())/2 - iV_GetTextAboveBase();
if (psWidget->style & WBUT_TXTCENTRE) //check for centering, calculate offset. if (psWidget->style & WBUT_TXTCENTRE) //check for centering, calculate offset.
@ -1699,7 +1699,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; return;
} }

View File

@ -305,7 +305,9 @@ void intUpdateQuantity(WIDGET *psWidget, W_CONTEXT *psContext)
psTemplate = FactoryGetTemplate(StructureGetFactory(Structure)); psTemplate = FactoryGetTemplate(StructureGetFactory(Structure));
int remaining = getProduction(Structure, psTemplate).numRemaining(); int remaining = getProduction(Structure, psTemplate).numRemaining();
snprintf(Label->aText, sizeof(Label->aText), "%d", remaining); char tmp[20];
ssprintf(tmp, "%d", remaining);
Label->aText = QString::fromUtf8(tmp);
Label->style &= ~WIDG_HIDDEN; Label->style &= ~WIDG_HIDDEN;
} }
else else
@ -331,12 +333,14 @@ void intAddFactoryInc(WIDGET *psWidget, W_CONTEXT *psContext)
Structure->pStructureType->type == REF_VTOL_FACTORY), Structure->pStructureType->type == REF_VTOL_FACTORY),
"Structure is not a factory"); "Structure is not a factory");
snprintf(Label->aText, sizeof(Label->aText), "%u", Factory->psAssemblyPoint->factoryInc + 1); char tmp[20];
ssprintf(tmp, "%u", Factory->psAssemblyPoint->factoryInc + 1);
Label->aText = QString::fromUtf8(tmp);
Label->style &= ~WIDG_HIDDEN; Label->style &= ~WIDG_HIDDEN;
} }
else else
{ {
Label->aText[0] = '\0'; Label->aText.clear();
Label->style |= WIDG_HIDDEN; Label->style |= WIDG_HIDDEN;
} }
} }
@ -367,19 +371,21 @@ void intAddProdQuantity(WIDGET *psWidget, W_CONTEXT *psContext)
// now find out how many we have built // now find out how many we have built
if (entry.isValid()) if (entry.isValid())
{ {
char tmp[40];
if (psStructure->pFunctionality->factory.productionLoops != 0) if (psStructure->pFunctionality->factory.productionLoops != 0)
{ {
snprintf(Label->aText, sizeof(Label->aText), "%u/%u", entry.numRemaining(), entry.quantity); ssprintf(tmp, "%u/%u", entry.numRemaining(), entry.quantity);
} }
else else
{ {
snprintf(Label->aText, sizeof(Label->aText), "%u", entry.numRemaining()); ssprintf(tmp, "%u", entry.numRemaining());
} }
Label->aText = QString::fromUtf8(tmp);
Label->style &= ~WIDG_HIDDEN; Label->style &= ~WIDG_HIDDEN;
} }
else else
{ {
Label->aText[0] = '\0'; Label->aText.clear();
Label->style |= WIDG_HIDDEN; Label->style |= WIDG_HIDDEN;
} }
} }
@ -398,22 +404,24 @@ void intAddLoopQuantity(WIDGET *psWidget, W_CONTEXT *psContext)
if (psFactory->productionLoops == INFINITE_PRODUCTION) if (psFactory->productionLoops == INFINITE_PRODUCTION)
{ {
sstrcpy(Label->aText, ""); Label->aText = QString::fromUtf8("");
} }
else if (psFactory->productionLoops != 0) else if (psFactory->productionLoops != 0)
{ {
snprintf(Label->aText, sizeof(Label->aText), "%u", psFactory->productionLoops + DEFAULT_LOOP); char tmp[20];
ssprintf(tmp, "%u", psFactory->productionLoops + DEFAULT_LOOP);
Label->aText = QString::fromUtf8(tmp);
} }
else else
{ {
Label->aText[0] = '\0'; // Don't show "1" loop. Label->aText.clear(); // Don't show "1" loop.
} }
Label->style &= ~WIDG_HIDDEN; Label->style &= ~WIDG_HIDDEN;
} }
else else
{ {
//hide the label if no factory //hide the label if no factory
Label->aText[0] = '\0'; Label->aText.clear();
Label->style |= WIDG_HIDDEN; Label->style |= WIDG_HIDDEN;
} }
} }
@ -432,12 +440,14 @@ void intUpdateCommandSize(WIDGET *psWidget, W_CONTEXT *psContext)
ASSERT(psDroid->droidType == DROID_COMMAND, ASSERT(psDroid->droidType == DROID_COMMAND,
"Droid is not a command droid"); "Droid is not a command droid");
ssprintf(Label->aText, "%u/%u", psDroid->psGroup ? psDroid->psGroup->getNumMembers() : 0, cmdDroidMaxGroup(psDroid)); char tmp[40];
ssprintf(tmp, "%u/%u", psDroid->psGroup ? psDroid->psGroup->getNumMembers() : 0, cmdDroidMaxGroup(psDroid));
Label->aText = QString::fromUtf8(tmp);
Label->style &= ~WIDG_HIDDEN; Label->style &= ~WIDG_HIDDEN;
} }
else else
{ {
Label->aText[0] = '\0'; Label->aText.clear();
Label->style |= WIDG_HIDDEN; Label->style |= WIDG_HIDDEN;
} }
} }
@ -447,7 +457,6 @@ void intUpdateCommandExp(WIDGET *psWidget, W_CONTEXT *psContext)
{ {
W_LABEL *Label = (W_LABEL *)psWidget; W_LABEL *Label = (W_LABEL *)psWidget;
BASE_OBJECT *psObj = (BASE_OBJECT *)Label->pUserData; BASE_OBJECT *psObj = (BASE_OBJECT *)Label->pUserData;
SDWORD i, numStars;
// Get the object associated with this widget. // Get the object associated with this widget.
if (psObj != NULL && !isDead(psObj)) if (psObj != NULL && !isDead(psObj))
@ -457,18 +466,13 @@ void intUpdateCommandExp(WIDGET *psWidget, W_CONTEXT *psContext)
ASSERT(psObj->type == OBJ_DROID, "Invalid droid pointer"); ASSERT(psObj->type == OBJ_DROID, "Invalid droid pointer");
ASSERT(psDroid->droidType == DROID_COMMAND, "Droid is not a command droid"); ASSERT(psDroid->droidType == DROID_COMMAND, "Droid is not a command droid");
numStars = getDroidLevel(psDroid); int numStars = std::max((int)getDroidLevel(psDroid) - 1, 0);
numStars = (numStars >= 1) ? (numStars - 1) : 0; Label->aText = QString(numStars, '*');
for (i = 0; i < numStars; i++)
{
Label->aText[i] = '*';
}
Label->aText[i] = '\0';
Label->style &= ~WIDG_HIDDEN; Label->style &= ~WIDG_HIDDEN;
} }
else else
{ {
Label->aText[0] = '\0'; Label->aText.clear();
Label->style |= WIDG_HIDDEN; Label->style |= WIDG_HIDDEN;
} }
} }
@ -478,7 +482,7 @@ void intUpdateCommandFact(WIDGET *psWidget, W_CONTEXT *psContext)
{ {
W_LABEL *Label = (W_LABEL *)psWidget; W_LABEL *Label = (W_LABEL *)psWidget;
BASE_OBJECT *psObj = (BASE_OBJECT *)Label->pUserData; BASE_OBJECT *psObj = (BASE_OBJECT *)Label->pUserData;
SDWORD i, cIndex, start; SDWORD i, start;
// Get the object associated with this widget. // Get the object associated with this widget.
if (psObj != NULL && !isDead(psObj)) if (psObj != NULL && !isDead(psObj))
@ -502,21 +506,19 @@ void intUpdateCommandFact(WIDGET *psWidget, W_CONTEXT *psContext)
start = DSS_ASSPROD_VTOL_SHIFT; start = DSS_ASSPROD_VTOL_SHIFT;
} }
cIndex = 0; Label->aText.clear();
for (i = 0; i < 5; ++i) // TODO Support up to MAX_FACTORY (which won't fit in the ugly secondaryOrder bitmask hack). for (i = 0; i < 5; ++i) // TODO Support up to MAX_FACTORY (which won't fit in the ugly secondaryOrder bitmask hack).
{ {
if (psDroid->secondaryOrder & (1 << (i + start))) if (psDroid->secondaryOrder & (1 << (i + start)))
{ {
Label->aText[cIndex] = (char)('0' + i + 1); Label->aText.append((char)('0' + i + 1));
cIndex += 1;
} }
} }
Label->aText[cIndex] = '\0';
Label->style &= ~WIDG_HIDDEN; Label->style &= ~WIDG_HIDDEN;
} }
else else
{ {
Label->aText[0] = '\0'; Label->aText.clear();
Label->style |= WIDG_HIDDEN; Label->style |= WIDG_HIDDEN;
} }
} }
@ -1800,12 +1802,14 @@ void intDisplayNumber(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_
} }
else else
{ {
snprintf(Label->aText, sizeof(Label->aText), "%02u", Quantity); char tmp[20];
ssprintf(tmp, "%02u", Quantity);
Label->aText = QString::fromUtf8(tmp);
for (int i = 0; Label->aText[i]; ++i) for (int i = 0; i < Label->aText.size(); ++i)
{ {
iV_DrawImage(IntImages, (UWORD)(IMAGE_0 + (Label->aText[i] - '0')), x, y); iV_DrawImage(IntImages, (UWORD)(IMAGE_0 + (Label->aText.toUtf8()[i] - '0')), x, y);
x += iV_GetImageWidth(IntImages, (UWORD)(IMAGE_0 + (Label->aText[i] - '0'))) + 1; x += iV_GetImageWidth(IntImages, (UWORD)(IMAGE_0 + (Label->aText.toUtf8()[i] - '0'))) + 1;
} }
} }
} }

View File

@ -446,9 +446,9 @@ bool runLoadSave(bool bResetMissionWidgets)
if (mode) // Loading, return that entry. if (mode) // Loading, return that entry.
{ {
if( ((W_BUTTON *)widgGetFromID(psRequestScreen,id))->pText ) if (!((W_BUTTON *)widgGetFromID(psRequestScreen,id))->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 else
{ {
@ -470,14 +470,15 @@ bool runLoadSave(bool bResetMissionWidgets)
sEdInit.y = widgGetFromID(psRequestScreen,id)->y; sEdInit.y = widgGetFromID(psRequestScreen,id)->y;
sEdInit.width = widgGetFromID(psRequestScreen,id)->width; sEdInit.width = widgGetFromID(psRequestScreen,id)->width;
sEdInit.height= widgGetFromID(psRequestScreen,id)->height; sEdInit.height= widgGetFromID(psRequestScreen,id)->height;
sEdInit.pText = ((W_BUTTON *)widgGetFromID(psRequestScreen,id))->pText; QByteArray textBytes = ((W_BUTTON *)widgGetFromID(psRequestScreen,id))->pText.toUtf8();
sEdInit.pText = textBytes.constData();
sEdInit.pBoxDisplay = displayLoadSaveEdit; sEdInit.pBoxDisplay = displayLoadSaveEdit;
widgAddEditBox(psRequestScreen, &sEdInit); widgAddEditBox(psRequestScreen, &sEdInit);
if (((W_BUTTON *)widgGetFromID(psRequestScreen,id))->pText != NULL) if (!((W_BUTTON *)widgGetFromID(psRequestScreen,id))->pText.isEmpty())
{ {
snprintf(sDelete, sizeof(sDelete), "%s%s%s", NewSaveGamePath, snprintf(sDelete, sizeof(sDelete), "%s%s%s", NewSaveGamePath,
((W_BUTTON *)widgGetFromID(psRequestScreen,id))->pText, sExt); ((W_BUTTON *)widgGetFromID(psRequestScreen,id))->pText.toUtf8().constData(), sExt);
} }
else else
{ {
@ -524,8 +525,8 @@ bool runLoadSave(bool bResetMissionWidgets)
if( i != chosenSlotId) if( i != chosenSlotId)
{ {
if( ((W_BUTTON *)widgGetFromID(psRequestScreen,i))->pText if(!((W_BUTTON *)widgGetFromID(psRequestScreen,i))->pText.isEmpty()
&& strcmp( sTemp, ((W_BUTTON *)widgGetFromID(psRequestScreen,i))->pText ) ==0) && strcmp(sTemp, ((W_BUTTON *)widgGetFromID(psRequestScreen,i))->pText.toUtf8().constData()) == 0)
{ {
widgDelete(psRequestScreen,SAVEENTRY_EDIT); //unselect this box, and go back .. widgDelete(psRequestScreen,SAVEENTRY_EDIT); //unselect this box, and go back ..
widgReveal(psRequestScreen,chosenSlotId); widgReveal(psRequestScreen,chosenSlotId);
@ -681,9 +682,9 @@ static void displayLoadSlot(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ
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_SetFont(font_regular); // font
iV_SetTextColour(WZCOL_FORM_TEXT); iV_SetTextColour(WZCOL_FORM_TEXT);

View File

@ -1999,8 +1999,9 @@ UDWORD missionGetReinforcementTime(void)
} }
//fills in a hours(if bHours = true), minutes and seconds display for a given time in 1000th sec //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! //this is only for the transporter timer - never have hours!
if (time == LZ_COMPROMISED_TIME) if (time == LZ_COMPROMISED_TIME)
{ {
@ -2012,6 +2013,7 @@ static void fillTimeDisplay(char *psText, UDWORD time, bool bHours)
struct tm *tmp = localtime(&secs); struct tm *tmp = localtime(&secs);
strftime(psText, WIDG_MAXSTR, bHours ? "%H:%M:%S" : "%H:%M", tmp); strftime(psText, WIDG_MAXSTR, bHours ? "%H:%M:%S" : "%H:%M", tmp);
} }
text = QString::fromUtf8(psText);
} }

View File

@ -1212,7 +1212,7 @@ static void showPasswordLabel( WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset,
iV_SetFont(font_large); iV_SetFont(font_large);
iV_SetTextColour(WZCOL_FORM_TEXT); iV_SetTextColour(WZCOL_FORM_TEXT);
iV_DrawText(psLab->aText, fx, fy); iV_DrawText(psLab->aText.toUtf8().constData(), fx, fy);
iV_SetTextColour(WZCOL_TEXT_MEDIUM); iV_SetTextColour(WZCOL_TEXT_MEDIUM);
} }
@ -3679,7 +3679,7 @@ void frontendMultiMessages(void)
void runMultiOptions(void) void runMultiOptions(void)
{ {
static UDWORD lastrefresh = 0; static UDWORD lastrefresh = 0;
char sTemp[128], oldGameMap[128]; char oldGameMap[128];
int oldMaxPlayers; int oldMaxPlayers;
PLAYERSTATS playerStats; PLAYERSTATS playerStats;
W_CONTEXT context; W_CONTEXT context;
@ -3758,15 +3758,16 @@ void runMultiOptions(void)
LEVEL_DATASET *mapData; LEVEL_DATASET *mapData;
bool isHoverPreview; bool isHoverPreview;
if (runMultiRequester(id, &id, (char *)&sTemp, &mapData, &isHoverPreview)) QString sTemp;
if (runMultiRequester(id, &id, &sTemp, &mapData, &isHoverPreview))
{ {
Sha256 oldGameHash; Sha256 oldGameHash;
switch(id) switch(id)
{ {
case MULTIOP_PNAME: case MULTIOP_PNAME:
sstrcpy(sPlayer, sTemp); sstrcpy(sPlayer, sTemp.toUtf8().constData());
widgSetString(psWScreen,MULTIOP_PNAME,sTemp); widgSetString(psWScreen, MULTIOP_PNAME, sTemp.toUtf8().constData());
removeWildcards((char*)sPlayer); removeWildcards((char*)sPlayer);

View File

@ -269,7 +269,7 @@ void displayRequestOption(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIEL
UDWORD y = yOffset+psWidget->y; UDWORD y = yOffset+psWidget->y;
char butString[255]; 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); //draw box
@ -631,7 +631,7 @@ static void closeMultiRequester(void)
return; 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 hoverId = 0;
static unsigned hoverStartTime = 0; static unsigned hoverStartTime = 0;
@ -660,7 +660,7 @@ bool runMultiRequester(UDWORD id, UDWORD *mode, char *chosen, LEVEL_DATASET **ch
} }
if (id >= M_REQUEST_BUT && id <= M_REQUEST_BUTM) // chose a file. 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; *chosenValue = (LEVEL_DATASET *)((W_BUTTON *)widgGetFromID(psRScreen,id))->pUserData;
*mode = context; *mode = context;

View File

@ -31,7 +31,7 @@
extern void addMultiRequest(const char* searchDir, const char* fileExtension, UDWORD id,UBYTE mapCam, UBYTE numPlayers); extern void addMultiRequest(const char* searchDir, const char* fileExtension, UDWORD id,UBYTE mapCam, UBYTE numPlayers);
extern bool multiRequestUp; extern bool multiRequestUp;
extern W_SCREEN *psRScreen; // requester stuff. extern W_SCREEN *psRScreen; // requester stuff.
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);
extern void displayRequestOption(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours); extern void displayRequestOption(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
// multimenu // multimenu

View File

@ -994,7 +994,7 @@ bool transporterIsEmpty(const DROID *psTransporter)
|| psTransporter->psGroup->psList == psTransporter); || psTransporter->psGroup->psList == psTransporter);
} }
static void intSetTransCapacityLabel(char *Label) static void intSetTransCapacityLabel(QString &text)
{ {
UDWORD capacity = TRANSPORTER_CAPACITY; UDWORD capacity = TRANSPORTER_CAPACITY;
@ -1005,8 +1005,9 @@ static void intSetTransCapacityLabel(char *Label)
//change round the way the remaining capacity is displayed - show 0/10 when empty now //change round the way the remaining capacity is displayed - show 0/10 when empty now
capacity = TRANSPORTER_CAPACITY - capacity; capacity = TRANSPORTER_CAPACITY - capacity;
Label[0] = (UBYTE)('0' + capacity / 10); char tmp[40];
Label[1] = (UBYTE)('0' + capacity % 10); ssprintf(tmp, "%02u/10", capacity);
text = QString::fromUtf8(tmp);
} }
} }