Merge branch 'bugfixes'

Conflicts:
	lib/widget/bar.cpp
	lib/widget/button.cpp
	lib/widget/button.h
	lib/widget/editbox.cpp
	lib/widget/form.cpp
	lib/widget/form.h
	lib/widget/label.cpp
	lib/widget/slider.cpp
	lib/widget/slider.h
	lib/widget/widgbase.h
	lib/widget/widget.cpp
	src/hci.cpp
	src/intdisplay.cpp
master
Cyp 2013-01-29 16:22:16 +01:00
commit c7c6534c7c
35 changed files with 859 additions and 801 deletions

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
# Copyright (c) 2012 dak180
# See http://opensource.org/licenses/bsd-license.php for licence terms
@ -6,7 +6,7 @@
# autorevision - extracts metadata about the head version from your repository.
# Usage message.
function arUsage {
arUsage() {
cat > "/dev/stderr" << EOF
usage: ./autorevision {-t output-type | -s symbol} [-o cache-file [-f] ] [-V]
Options include:
@ -29,6 +29,8 @@ The folowing are valid output types:
js = javascript file
java = Java file
javaprop = Java properties file
tex = (La)TeX file
m4 = m4 file
The following are valid symbols:
VCS_TYPE
@ -46,7 +48,7 @@ EOF
}
# Config
ARVERSION="1.1"
ARVERSION="1.4"
TARGETFILE="/dev/stdout"
while getopts ":t:o:s:Vf" OPTION; do
case "${OPTION}" in
@ -73,14 +75,14 @@ while getopts ":t:o:s:Vf" OPTION; do
esac
done
if [[ ! -z "${VAROUT}" ]] && [[ ! -z "${AFILETYPE}" ]]; then
if [ ! -z "${VAROUT}" ] && [ ! -z "${AFILETYPE}" ]; then
# If both -s and -t are specified:
echo "error: Improper argument combination." 1>&2
exit 1
elif [[ -z "${VAROUT}" ]] && [[ -z "${AFILETYPE}" ]]; then
elif [ -z "${VAROUT}" ] && [ -z "${AFILETYPE}" ]; then
# If neither -s or -t are specified:
arUsage
elif [[ -z "${CACHEFILE}" ]] && [[ "${CACHEFORCE}" = "1" ]]; then
elif [ -z "${CACHEFILE}" ] && [ "${CACHEFORCE}" = "1" ]; then
# If -f is specified without -o:
arUsage
fi
@ -88,20 +90,20 @@ fi
# Functions to extract data from different repo types.
# For git repos
function gitRepo {
gitRepo() {
cd "$(git rev-parse --show-toplevel)"
VCS_TYPE="git"
VCS_BASENAME="$(basename "${PWD}")"
# Is the working copy clean?
git diff --quiet HEAD &> /dev/null
# Is the working copy clean?
test -z "$(git status -uno --porcelain)"
VCS_WC_MODIFIED="${?}"
# Enumeration of changesets
VCS_NUM="$(git rev-list --count HEAD 2>/dev/null)"
if [[ -z "${VCS_NUM}" ]]; then
if [ -z "${VCS_NUM}" ]; then
echo "warning: Counting the number of revisions may be slower due to an outdated git version less than 1.7.2.3. If something breaks, please update it." 1>&2
VCS_NUM="$(git rev-list HEAD | wc -l)"
fi
@ -122,7 +124,7 @@ function gitRepo {
VCS_TAG="$(echo "${DESCRIPTION}" | sed -e "s:-g${VCS_SHORT_HASH}\$::" | sed -e 's:-[0-9]*$::')"
# Distance to last tag or an alias of VCS_NUM if there is no tag
if [[ ! -z "${DESCRIPTION}" ]]; then
if [ ! -z "${DESCRIPTION}" ]; then
VCS_TICK="$(echo "${DESCRIPTION}" | sed -e "s:${VCS_TAG}-::" -e "s:-g${VCS_SHORT_HASH}::")"
else
VCS_TICK="${VCS_NUM}"
@ -133,7 +135,7 @@ function gitRepo {
}
# For hg repos
function hgRepo {
hgRepo() {
cd "$(hg root)"
VCS_TYPE="hg"
@ -157,7 +159,7 @@ function hgRepo {
# or branch if no bookmark
VCS_BRANCH="$(hg id -B | cut -d ' ' -f 1)"
# Fall back to the branch if there are no bookmarks
if [[ -z "${VCS_BRANCH}" ]]; then
if [ -z "${VCS_BRANCH}" ]; then
VCS_BRANCH="$(hg id -b)"
fi
@ -165,7 +167,7 @@ function hgRepo {
VCS_TAG="$(hg log -r "${VCS_NUM}" -l 1 --template '{latesttag}\n' 2>/dev/null | sed -e 's:qtip::' -e 's:tip::' -e 's:qbase::' -e 's:qparent::' -e "s:$(hg --config 'extensions.color=' --color never qtop 2>/dev/null)::" | cut -d ' ' -f 1)"
# Distance to last tag or an alias of VCS_NUM if there is no tag
if [[ ! -z "${VCS_TAG}" ]]; then
if [ ! -z "${VCS_TAG}" ]; then
VCS_TICK="$(hg log -r "${VCS_NUM}" -l 1 --template '{latesttagdistance}\n' 2>/dev/null)"
else
VCS_TICK="${VCS_NUM}"
@ -176,7 +178,7 @@ function hgRepo {
}
# For bzr repos
function bzrRepo {
bzrRepo() {
cd "$(bzr root)"
VCS_TYPE="bzr"
@ -194,7 +196,7 @@ function bzrRepo {
VCS_FULL_HASH="$(bzr version-info --custom --template='{revision_id}\n')"
# The short hash
VCS_SHORT_HASH="$VCS_NUM"
VCS_SHORT_HASH="${VCS_NUM}"
# Nick of the current branch
VCS_BRANCH="$(bzr nick)"
@ -203,7 +205,7 @@ function bzrRepo {
VCS_TAG="$(bzr tags --sort=time | sed '/?$/d' | tail -n1 | cut -d ' ' -f1)"
# Distance to last tag or an alias of VCS_NUM if there is no tag
if [[ ! -z "${VCS_TAG}" ]]; then
if [ ! -z "${VCS_TAG}" ]; then
VCS_TICK="$(bzr log --line -r "tag:${VCS_TAG}.." | tail -n +2 | wc -l | sed -e 's:^ *::')"
else
VCS_TICK="${VCS_NUM}"
@ -214,17 +216,17 @@ function bzrRepo {
}
# For svn repos
function svnRepo {
svnRepo() {
VCS_TYPE="svn"
case "${PWD}" in
/*trunk*|/*branches*|/*tags*)
fn="${PWD}"
while [[ "$(basename "${fn}")" != 'trunk' ]] && [[ "$(basename "${fn}")" != 'branches' ]] && [[ "$(basename "${fn}")" != 'tags' ]] && [[ "$(basename "${fn}")" != '/' ]]; do
while [ "$(basename "${fn}")" != 'trunk' ] && [ "$(basename "${fn}")" != 'branches' ] && [ "$(basename "${fn}")" != 'tags' ] && [ "$(basename "${fn}")" != '/' ]; do
fn="$(dirname "${fn}")"
done
fn="$(dirname "${fn}")"
if [[ "${fn}" == '/' ]]; then
if [ "${fn}" = '/' ]; then
VCS_BASENAME="$(basename "${PWD}")"
else
VCS_BASENAME="$(basename "${fn}")"
@ -250,7 +252,7 @@ function svnRepo {
VCS_FULL_HASH="${SVNVERSION}"
# The short hash
VCS_SHORT_HASH="$VCS_NUM"
VCS_SHORT_HASH="${VCS_NUM}"
# Current branch
case "${PWD}" in
@ -260,13 +262,13 @@ function svnRepo {
while :
do
base="$(basename "${fn}")"
if [[ "$base" = 'trunk' ]]; then
if [ "${base}" = 'trunk' ]; then
VCS_BRANCH='trunk'
break
elif [[ "${base}" = 'branches' ]] || [[ "${base}" = 'tags' ]]; then
elif [ "${base}" = 'branches' ] || [ "${base}" = 'tags' ]; then
VCS_BRANCH="${lastbase}"
break
elif [[ "${base}" = '/' ]]; then
elif [ "${base}" = '/' ]; then
VCS_BRANCH=""
break
fi
@ -290,7 +292,7 @@ function svnRepo {
# Functions to output data in different formats.
# For header output
function hOutput {
hOutput() {
cat > "${TARGETFILE}" << EOF
/* Generated by autorevision - do not hand-hack! */
#ifndef AUTOREVISION_H
@ -316,7 +318,7 @@ EOF
}
# A header output for use with xcode to populate info.plist strings
function xcodeOutput {
xcodeOutput() {
cat > "${TARGETFILE}" << EOF
/* Generated by autorevision - do not hand-hack! */
#ifndef AUTOREVISION_H
@ -342,7 +344,7 @@ EOF
}
# For bash output
function shOutput {
shOutput() {
cat > "${TARGETFILE}" << EOF
# Generated by autorevision - do not hand-hack!
@ -364,7 +366,7 @@ EOF
}
# For Python output
function pyOutput {
pyOutput() {
case "${VCS_WC_MODIFIED}" in
0) VCS_WC_MODIFIED="False" ;;
1) VCS_WC_MODIFIED="True" ;;
@ -390,7 +392,7 @@ EOF
}
# For Perl output
function plOutput {
plOutput() {
cat << EOF
# Generated by autorevision - do not hand-hack!
@ -412,7 +414,7 @@ EOF
}
# For lua output
function luaOutput {
luaOutput() {
case "${VCS_WC_MODIFIED}" in
0) VCS_WC_MODIFIED="false" ;;
1) VCS_WC_MODIFIED="true" ;;
@ -438,7 +440,7 @@ EOF
}
# For php output
function phpOutput {
phpOutput() {
case "${VCS_WC_MODIFIED}" in
0) VCS_WC_MODIFIED="false" ;;
1) VCS_WC_MODIFIED="true" ;;
@ -466,7 +468,7 @@ EOF
}
# For ini output
function iniOutput {
iniOutput() {
case "${VCS_WC_MODIFIED}" in
0) VCS_WC_MODIFIED="false" ;;
1) VCS_WC_MODIFIED="true" ;;
@ -489,7 +491,7 @@ EOF
}
# For javascript output
function jsOutput {
jsOutput() {
case "${VCS_WC_MODIFIED}" in
1) VCS_WC_MODIFIED="true" ;;
0) VCS_WC_MODIFIED="false" ;;
@ -522,7 +524,7 @@ EOF
}
# For Java output
function javaOutput {
javaOutput() {
case "${VCS_WC_MODIFIED}" in
1) VCS_WC_MODIFIED="true" ;;
0) VCS_WC_MODIFIED="false" ;;
@ -550,7 +552,7 @@ EOF
}
# For Java properties output
function javapropOutput {
javapropOutput() {
case "${VCS_WC_MODIFIED}" in
1) VCS_WC_MODIFIED="true" ;;
0) VCS_WC_MODIFIED="false" ;;
@ -573,22 +575,61 @@ VCS_WC_MODIFIED=${VCS_WC_MODIFIED}
EOF
}
# For m4 output
m4Output() {
cat > "${TARGETFILE}" << EOF
define(\`VCS_TYPE', \`${VCS_TYPE}')dnl
define(\`VCS_BASENAME', \`${VCS_BASENAME}')dnl
define(\`VCS_NUM', \`${VCS_NUM}')dnl
define(\`VCS_DATE', \`${VCS_DATE}')dnl
define(\`VCS_BRANCH', \`${VCS_BRANCH}')dnl
define(\`VCS_TAG', \`${VCS_TAG}')dnl
define(\`VCS_TICK', \`${VCS_TICK}')dnl
define(\`VCS_FULLHASH', \`${VCS_FULL_HASH}')dnl
define(\`VCS_SHIRTHASH', \`${VCS_SHORT_HASH}')dnl
define(\`VCS_WC_MODIFIED', \`${VCS_WC_MODIFIED}')dnl
EOF
}
# For (La)TeX output
texOutput() {
case "${VCS_WC_MODIFIED}" in
0) VCS_WC_MODIFIED="false" ;;
1) VCS_WC_MODIFIED="true" ;;
esac
cat > "${TARGETFILE}" << EOF
% Generated by autorevision - do not hand-hack!
\def \vcsType {${VCS_TYPE}}
\def \vcsBasename {${VCS_BASENAME}}
\def \vcsNum {${VCS_NUM}}
\def \vcsDate {${VCS_DATE}}
\def \vcsBranch {${VCS_BRANCH}}
\def \vcsTag {${VCS_TAG}}
\def \vcsTick {${VCS_TICK}}
\def \vcsFullHash {${VCS_FULL_HASH}}
\def \vcsShortHash {${VCS_SHORT_HASH}}
\def \vcsWCModified {${VCS_WC_MODIFIED}}
\endinput
EOF
}
# Detect and collect repo data.
if [[ -f "${CACHEFILE}" ]] && [[ "${CACHEFORCE}" = "1" ]]; then
if [ -f "${CACHEFILE}" ] && [ "${CACHEFORCE}" = "1" ]; then
# When requested only read from the cache to populate our symbols.
source "${CACHEFILE}"
elif [[ ! -z "$(git rev-parse HEAD 2>/dev/null)" ]]; then
elif [ ! -z "$(git rev-parse HEAD 2>/dev/null)" ]; then
gitRepo
elif [[ ! -z "$(hg root 2>/dev/null)" ]]; then
elif [ ! -z "$(hg root 2>/dev/null)" ]; then
hgRepo
elif [[ ! -z "$(bzr root 2>/dev/null)" ]]; then
elif [ ! -z "$(bzr root 2>/dev/null)" ]; then
bzrRepo
elif [[ ! -z "$(svn info 2>/dev/null)" ]]; then
elif [ ! -z "$(svn info 2>/dev/null)" ]; then
svnRepo
elif [[ -f "${CACHEFILE}" ]]; then
elif [ -f "${CACHEFILE}" ]; then
# We are not in a repo; try to use a previously generated cache to populate our symbols.
source "${CACHEFILE}"
. "${CACHEFILE}"
else
echo "error: No repo or cache detected." 1>&2
exit 1
@ -596,55 +637,59 @@ fi
# -s output is handled here.
if [[ ! -z "${VAROUT}" ]]; then
if [[ "${VAROUT}" = "VCS_TYPE" ]]; then
if [ ! -z "${VAROUT}" ]; then
if [ "${VAROUT}" = "VCS_TYPE" ]; then
echo "${VCS_TYPE}"
elif [[ "${VAROUT}" = "VCS_BASENAME" ]]; then
elif [ "${VAROUT}" = "VCS_BASENAME" ]; then
echo "${VCS_BASENAME}"
elif [[ "${VAROUT}" = "VCS_NUM" ]]; then
elif [ "${VAROUT}" = "VCS_NUM" ]; then
echo "${VCS_NUM}"
elif [[ "${VAROUT}" = "VCS_DATE" ]]; then
elif [ "${VAROUT}" = "VCS_DATE" ]; then
echo "${VCS_DATE}"
elif [[ "${VAROUT}" = "VCS_BRANCH" ]]; then
elif [ "${VAROUT}" = "VCS_BRANCH" ]; then
echo "${VCS_BRANCH}"
elif [[ "${VAROUT}" = "VCS_TAG" ]]; then
elif [ "${VAROUT}" = "VCS_TAG" ]; then
echo "${VCS_TAG}"
elif [[ "${VAROUT}" = "VCS_TICK" ]]; then
elif [ "${VAROUT}" = "VCS_TICK" ]; then
echo "${VCS_TICK}"
elif [[ "${VAROUT}" = "VCS_FULL_HASH" ]]; then
elif [ "${VAROUT}" = "VCS_FULL_HASH" ]; then
echo "${VCS_FULL_HASH}"
elif [[ "${VAROUT}" = "VCS_SHORT_HASH" ]]; then
elif [ "${VAROUT}" = "VCS_SHORT_HASH" ]; then
echo "${VCS_SHORT_HASH}"
elif [[ "${VAROUT}" = "VCS_WC_MODIFIED" ]]; then
elif [ "${VAROUT}" = "VCS_WC_MODIFIED" ]; then
echo "${VCS_WC_MODIFIED}"
fi
fi
# Detect requested output type and use it.
if [[ ! -z "${AFILETYPE}" ]]; then
if [[ "${AFILETYPE}" = "h" ]]; then
if [ ! -z "${AFILETYPE}" ]; then
if [ "${AFILETYPE}" = "h" ]; then
hOutput
elif [[ "${AFILETYPE}" = "xcode" ]]; then
elif [ "${AFILETYPE}" = "xcode" ]; then
xcodeOutput
elif [[ "${AFILETYPE}" = "sh" ]]; then
elif [ "${AFILETYPE}" = "sh" ]; then
shOutput
elif [[ "${AFILETYPE}" = "py" ]]; then
elif [ "${AFILETYPE}" = "py" ] || [ "${AFILETYPE}" = "python" ]; then
pyOutput
elif [[ "${AFILETYPE}" = "pl" ]]; then
elif [ "${AFILETYPE}" = "pl" ] || [ "${AFILETYPE}" = "perl" ]; then
plOutput
elif [[ "${AFILETYPE}" = "lua" ]]; then
elif [ "${AFILETYPE}" = "lua" ]; then
luaOutput
elif [[ "${AFILETYPE}" = "php" ]]; then
elif [ "${AFILETYPE}" = "php" ]; then
phpOutput
elif [[ "${AFILETYPE}" = "ini" ]]; then
elif [ "${AFILETYPE}" = "ini" ]; then
iniOutput
elif [[ "${AFILETYPE}" = "js" ]]; then
elif [ "${AFILETYPE}" = "js" ]; then
jsOutput
elif [[ "${AFILETYPE}" = "java" ]]; then
elif [ "${AFILETYPE}" = "java" ]; then
javaOutput
elif [[ "${AFILETYPE}" = "javaprop" ]]; then
elif [ "${AFILETYPE}" = "javaprop" ]; then
javapropOutput
elif [ "${AFILETYPE}" = "tex" ]; then
texOutput
elif [ "${AFILETYPE}" = "m4" ]; then
m4Output
else
echo "error: Not a valid output type." 1>&2
exit 1
@ -653,7 +698,7 @@ fi
# If requested, make a cache file.
if [[ ! -z "${CACHEFILE}" ]] && [[ ! "${CACHEFORCE}" = "1" ]]; then
if [ ! -z "${CACHEFILE}" ] && [ ! "${CACHEFORCE}" = "1" ]; then
TARGETFILE="${CACHEFILE}"
shOutput
fi

View File

@ -138,15 +138,10 @@ case ${host_os} in
AC_SUBST([WIN32_LIBS], [${WIN32_LIBS}])
LDFLAGS="-Wl,-subsystem,windows ${LDFLAGS}"
;;
*openbsd*)
AC_DEFINE([_XOPEN_SOURCE], 600, [Enable POSIX extensions if present])
# Make sure that backtrace_symbols_fd (GNU raw back trace extension) has some symbols to work with
LDFLAGS="-Wl,-export-dynamic ${LDFLAGS}"
;;
*)
# Some platforms don't need _XOPEN_SOURCE
case ${host_os} in
*freebsd*) ;;
*bsd* | dragonfly* | bitrig*) ;;
*)
AC_DEFINE([_XOPEN_SOURCE], 600, [Enable POSIX extensions if present])
;;

View File

@ -33,6 +33,8 @@
#include "types.h"
#include "lib/framework/utf.h"
#include "vector.h"
#include <vector>
/** Defines for all the key codes used. */
enum KEY_CODE
@ -156,6 +158,19 @@ enum MOUSE_KEY_CODE
MOUSE_BAD
};
struct MousePress
{
enum Action {None, Press, Release};
MousePress(Action action = None, MOUSE_KEY_CODE key = MOUSE_BAD) : action(action), key(key) {}
bool empty() const { return action == None; }
Action action;
MOUSE_KEY_CODE key;
Vector2i pos;
};
typedef std::vector<MousePress> MousePresses;
/** Tell the input system that we have lost the focus. */
extern void inputLoseFocus(void);
@ -184,9 +199,9 @@ extern uint16_t mouseY(void) WZ_DECL_PURE;
bool wzMouseInWindow();
/// Return the position of the mouse where it was clicked last.
Vector2i mousePressPos(MOUSE_KEY_CODE code) WZ_DECL_PURE;
Vector2i mousePressPos_DEPRECATED(MOUSE_KEY_CODE code) WZ_DECL_PURE;
/// Return the position of the mouse where it was released last.
Vector2i mouseReleasePos(MOUSE_KEY_CODE code) WZ_DECL_PURE;
Vector2i mouseReleasePos_DEPRECATED(MOUSE_KEY_CODE code) WZ_DECL_PURE;
/** This returns true if the mouse key is currently depressed. */
extern bool mouseDown(MOUSE_KEY_CODE code);
@ -235,6 +250,8 @@ extern bool getMouseWarp();
* to the key press (using the user's native layout).
*/
extern UDWORD inputGetKey(utf_32_char *unicode);
/// Returns all clicks/releases since last update.
MousePresses const &inputGetClicks();
/** Clear the input buffer. */
extern void inputClearBuffer(void);

View File

@ -87,9 +87,7 @@ static SDWORD dragX, dragY;
/** The current mouse button state */
static INPUT_STATE aMouseState[MOUSE_BAD];
/** The size of the input buffer */
#define INPUT_MAXSTR 512
static MousePresses mousePresses;
/** The input string buffer */
struct InputKey
@ -371,6 +369,12 @@ void WzMainWindow::mousePressEvent(QMouseEvent *event)
return; // not recognized mouse button
}
MousePress mousePress;
mousePress.action = MousePress::Press;
mousePress.key = idx;
mousePress.pos = Vector2i(mouseXPos, mouseYPos);
mousePresses.push_back(mousePress);
aMouseState[idx].pressPos.x = mouseXPos;
aMouseState[idx].pressPos.y = mouseYPos;
@ -435,6 +439,12 @@ void WzMainWindow::mouseReleaseEvent(QMouseEvent *event)
return; // not recognized mouse button
}
MousePress mousePress;
mousePress.action = MousePress::Release;
mousePress.key = idx;
mousePress.pos = Vector2i(mouseXPos, mouseYPos);
mousePresses.push_back(mousePress);
aMouseState[idx].releasePos.x = mouseXPos;
aMouseState[idx].releasePos.y = mouseYPos;
@ -768,12 +778,12 @@ bool wzMouseInWindow()
return mouseInWindow;
}
Vector2i mousePressPos(MOUSE_KEY_CODE code)
Vector2i mousePressPos_DEPRECATED(MOUSE_KEY_CODE code)
{
return aMouseState[code].pressPos;
}
Vector2i mouseReleasePos(MOUSE_KEY_CODE code)
Vector2i mouseReleasePos_DEPRECATED(MOUSE_KEY_CODE code)
{
return aMouseState[code].releasePos;
}
@ -910,6 +920,11 @@ UDWORD inputGetKey(utf_32_char *unicode)
return retVal;
}
MousePresses const &inputGetClicks()
{
return mousePresses;
}
/*!
* This is called once a frame so that the system can tell
* whether a key was pressed this turn or held down from the last frame.
@ -946,6 +961,8 @@ void inputNewFrame(void)
aMouseState[i].state = KEY_UP;
}
}
mousePresses.clear();
}
/*!

View File

@ -97,6 +97,7 @@ static SDWORD dragX, dragY;
/* The current mouse button state */
static INPUT_STATE aMouseState[MOUSE_BAD];
static MousePresses mousePresses;
/* The size of the input buffer */
@ -707,6 +708,11 @@ UDWORD inputGetKey(utf_32_char *unicode)
return retVal;
}
MousePresses const &inputGetClicks()
{
return mousePresses;
}
/*!
* This is called once a frame so that the system can tell
@ -744,6 +750,8 @@ void inputNewFrame(void)
aMouseState[i].state = KEY_UP;
}
}
mousePresses.clear();
}
/*!
@ -803,12 +811,12 @@ bool wzMouseInWindow()
return mouseInWindow;
}
Vector2i mousePressPos(MOUSE_KEY_CODE code)
Vector2i mousePressPos_DEPRECATED(MOUSE_KEY_CODE code)
{
return aMouseState[code].pressPos;
}
Vector2i mouseReleasePos(MOUSE_KEY_CODE code)
Vector2i mouseReleasePos_DEPRECATED(MOUSE_KEY_CODE code)
{
return aMouseState[code].releasePos;
}
@ -980,9 +988,16 @@ static void inputHandleMouseButtonEvent(SDL_MouseButtonEvent * buttonEvent)
case SDL_BUTTON_WHEELDOWN: mouseKeyCode = MOUSE_WDN; break;
}
MousePress mousePress;
mousePress.key = mouseKeyCode;
mousePress.pos = Vector2i(mouseXPos, mouseYPos);
switch (buttonEvent->type)
{
case SDL_MOUSEBUTTONDOWN:
mousePress.action = MousePress::Press;
mousePresses.push_back(mousePress);
aMouseState[mouseKeyCode].pressPos.x = mouseXPos;
aMouseState[mouseKeyCode].pressPos.y = mouseYPos;
if ( aMouseState[mouseKeyCode].state == KEY_UP
@ -1020,6 +1035,9 @@ static void inputHandleMouseButtonEvent(SDL_MouseButtonEvent * buttonEvent)
}
break;
case SDL_MOUSEBUTTONUP:
mousePress.action = MousePress::Release;
mousePresses.push_back(mousePress);
aMouseState[mouseKeyCode].releasePos.x = mouseXPos;
aMouseState[mouseKeyCode].releasePos.y = mouseYPos;
if (aMouseState[mouseKeyCode].state == KEY_PRESSED)

View File

@ -192,22 +192,22 @@ void widgSetMinorBarSize(W_SCREEN *psScreen, UDWORD id, UDWORD iValue)
/* Respond to a mouse moving over a barGraph */
void barGraphHiLite(W_BARGRAPH *psWidget, W_CONTEXT *psContext)
void W_BARGRAPH::highlight(W_CONTEXT *psContext)
{
if (psWidget->pTip)
if (pTip)
{
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, psContext->psScreen->TipFontID,
psContext->psForm->aColours,
x + psContext->xOffset, y + psContext->yOffset,
width, height);
}
}
/* Respond to the mouse moving off a barGraph */
void barGraphHiLiteLost(W_BARGRAPH *psWidget)
void W_BARGRAPH::highlightLost(W_CONTEXT *)
{
tipStop((WIDGET *)psWidget);
tipStop(this);
}

View File

@ -26,10 +26,14 @@
#include "widget.h"
struct W_BARGRAPH : public WIDGET
{
W_BARGRAPH(W_BARINIT const *init);
void highlight(W_CONTEXT *psContext);
void highlightLost(W_CONTEXT *);
WBAR_ORIENTATION barPos; // Orientation of the bar on the widget
UWORD majorSize; // Percentage of the main bar that is filled
UWORD minorSize; // Percentage of the minor bar if there is one
@ -51,12 +55,6 @@ extern W_BARGRAPH *barGraphCreate(const W_BARINIT *psInit);
/* Free the memory used by a barGraph */
extern void barGraphFree(W_BARGRAPH *psWidget);
/* Respond to a mouse moving over a barGraph */
extern void barGraphHiLite(W_BARGRAPH *psWidget, W_CONTEXT *psContext);
/* Respond to the mouse moving off a barGraph */
extern void barGraphHiLiteLost(W_BARGRAPH *psWidget);
/* The bar graph display function */
extern void barGraphDisplay(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);

View File

@ -179,8 +179,9 @@ void buttonSetState(W_BUTTON *psButton, UDWORD state)
/* Run a button widget */
void buttonRun(W_BUTTON *psButton)
void W_BUTTON::run(W_CONTEXT *)
{
W_BUTTON *psButton = this;
if (psButton->state & WBUTS_FLASH)
{
if (((realTime / 250) % 2) == 0)
@ -196,8 +197,9 @@ void buttonRun(W_BUTTON *psButton)
/* Respond to a mouse click */
void buttonClicked(W_BUTTON *psWidget, UDWORD 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 */
if (!(psWidget->state & (WBUTS_GREY | WBUTS_LOCKED)))
{
@ -223,8 +225,10 @@ void buttonClicked(W_BUTTON *psWidget, UDWORD key)
}
/* Respond to a mouse button up */
void buttonReleased(W_SCREEN *psScreen, W_BUTTON *psWidget, UDWORD key)
void W_BUTTON::released(W_CONTEXT *psContext, WIDGET_KEY key)
{
W_SCREEN *psScreen = psContext->psScreen;
W_BUTTON *psWidget = this;
if (psWidget->state & WBUTS_DOWN)
{
// Check this is the correct key
@ -239,8 +243,9 @@ void buttonReleased(W_SCREEN *psScreen, W_BUTTON *psWidget, UDWORD key)
/* Respond to a mouse moving over a button */
void buttonHiLite(W_BUTTON *psWidget, W_CONTEXT *psContext)
void W_BUTTON::highlight(W_CONTEXT *psContext)
{
W_BUTTON *psWidget = this;
psWidget->state |= WBUTS_HILITE;
if (psWidget->AudioCallback)
@ -260,8 +265,9 @@ void buttonHiLite(W_BUTTON *psWidget, W_CONTEXT *psContext)
/* Respond to the mouse moving off a button */
void buttonHiLiteLost(W_BUTTON *psWidget)
void W_BUTTON::highlightLost(W_CONTEXT *)
{
W_BUTTON *psWidget = this;
psWidget->state &= ~(WBUTS_DOWN | WBUTS_HILITE);
if (psWidget->pTip)
{

View File

@ -38,17 +38,16 @@
#define WBUTS_FLASH 0x0020 // Button flashing is enabled
#define WBUTS_FLASHON 0x0040 // Button is flashing
/* Respond to a mouse click */
void buttonClicked(struct W_BUTTON *psWidget, UDWORD key);
struct W_BUTTON : public WIDGET
{
W_BUTTON(W_BUTINIT const *init);
void clicked(W_CONTEXT *, WIDGET_KEY key)
{
buttonClicked(this, key);
}
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);
UDWORD state; // The current button state
const char *pText; // The text for the button
@ -71,18 +70,6 @@ extern void buttonFree(W_BUTTON *psWidget);
/* Initialise a button widget before running it */
extern void buttonInitialise(W_BUTTON *psWidget);
/* Run a button widget */
extern void buttonRun(W_BUTTON *psWidget);
/* Respond to a mouse button up */
extern void buttonReleased(W_SCREEN *psScreen, W_BUTTON *psWidget, UDWORD key);
/* Respond to a mouse moving over a button */
extern void buttonHiLite(W_BUTTON *psWidget, W_CONTEXT *psContext);
/* Respond to the mouse moving off a button */
extern void buttonHiLiteLost(W_BUTTON *psWidget);
/* Get a button's state */
extern UDWORD buttonGetState(W_BUTTON *psButton);

View File

@ -522,8 +522,9 @@ void W_EDITBOX::focusLost(W_SCREEN *psScreen)
/* Respond to a mouse moving over an edit box */
void editBoxHiLite(W_EDITBOX *psWidget)
void W_EDITBOX::highlight(W_CONTEXT *)
{
W_EDITBOX *psWidget = this;
if (psWidget->state & WEDBS_DISABLE)
{
return;
@ -539,8 +540,9 @@ void editBoxHiLite(W_EDITBOX *psWidget)
/* Respond to the mouse moving off an edit box */
void editBoxHiLiteLost(W_EDITBOX *psWidget)
void W_EDITBOX::highlightLost(W_CONTEXT *)
{
W_EDITBOX *psWidget = this;
if (psWidget->state & WEDBS_DISABLE)
{
return;

View File

@ -37,15 +37,19 @@
#define WEDBS_HILITE 0x0010 //
#define WEDBS_DISABLE 0x0020 // disable button from selection
struct W_EDITBOX : public WIDGET
{
W_EDITBOX(W_EDBINIT const *init);
void run(W_CONTEXT *psContext);
void initialise(); // Moves the cursor to the end.
void setString(char const *utf8);
void clicked(W_CONTEXT *psContext, WIDGET_KEY);
void clicked(W_CONTEXT *psContext, WIDGET_KEY key);
void highlight(W_CONTEXT *psContext);
void highlightLost(W_CONTEXT *psContext);
void focusLost(W_SCREEN *psScreen);
void run(W_CONTEXT *psContext);
UDWORD state; // The current edit box state
QString aText; // The text in the edit box
@ -74,12 +78,6 @@ private:
/* Create an edit box widget data structure */
extern W_EDITBOX *editBoxCreate(const W_EDBINIT *psInit);
/* Respond to a mouse moving over an edit box */
extern void editBoxHiLite(W_EDITBOX *psWidget);
/* Respond to the mouse moving off an edit box */
extern void editBoxHiLiteLost(W_EDITBOX *psWidget);
/* The edit box display function */
extern void editBoxDisplay(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);

View File

@ -991,8 +991,9 @@ static bool formPickTab(W_TABFORM *psForm, UDWORD fx, UDWORD fy,
extern UDWORD realTime; // FIXME Include a header...
/* Run a form widget */
void formRun(W_FORM *psWidget, W_CONTEXT *psContext)
void W_FORM::run(W_CONTEXT *psContext)
{
W_FORM *psWidget = this;
SDWORD mx, my;
TAB_POS sTabPos;
char *pTip;
@ -1087,8 +1088,9 @@ void formClearFlash(W_FORM *psWidget)
/* Respond to a mouse click */
void formClicked(W_FORM *psWidget, UDWORD key)
void W_FORM::clicked(W_CONTEXT *, WIDGET_KEY key)
{
W_FORM *psWidget = this;
W_CLICKFORM *psClickForm;
/* Stop the tip if there is one */
@ -1120,8 +1122,9 @@ void formClicked(W_FORM *psWidget, UDWORD key)
/* Respond to a mouse form up */
void formReleased(W_FORM *psWidget, UDWORD key, W_CONTEXT *psContext)
void W_FORM::released(W_CONTEXT *psContext, WIDGET_KEY key)
{
W_FORM *psWidget = this;
W_TABFORM *psTabForm;
W_CLICKFORM *psClickForm;
TAB_POS sTabPos;
@ -1168,8 +1171,9 @@ void formReleased(W_FORM *psWidget, UDWORD key, W_CONTEXT *psContext)
/* Respond to a mouse moving over a form */
void formHiLite(W_FORM *psWidget, W_CONTEXT *psContext)
void W_FORM::highlight(W_CONTEXT *psContext)
{
W_FORM *psWidget = this;
W_CLICKFORM *psClickForm;
if (psWidget->style & WFORM_CLICKABLE)
@ -1196,12 +1200,13 @@ void formHiLite(W_FORM *psWidget, W_CONTEXT *psContext)
/* Respond to the mouse moving off a form */
void formHiLiteLost(W_FORM *psWidget, W_CONTEXT *psContext)
void W_FORM::highlightLost(W_CONTEXT *psContext)
{
W_FORM *psWidget = this;
/* If one of the widgets were hilited that has to loose it as well */
if (psWidget->psLastHiLite != NULL)
{
widgHiLiteLost(psWidget->psLastHiLite, psContext);
psWidget->psLastHiLite->highlightLost(psContext);
}
if (psWidget->style & WFORM_TABBED)
{

View File

@ -27,18 +27,16 @@
#include "lib/widget/widget.h"
/* Respond to a mouse click */
extern void formClicked(W_FORM *psWidget, UDWORD key);
/* The standard form */
struct W_FORM : public WIDGET
{
W_FORM(W_FORMINIT const *init);
void clicked(W_CONTEXT *, WIDGET_KEY key)
{
formClicked(this, key);
}
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);
bool disableChildren; ///< Disable all child widgets if true
UWORD Ax0, Ay0, Ax1, Ay1; ///< Working coords for animations.
@ -164,18 +162,6 @@ extern void formSetFlash(W_FORM *psWidget);
/* Set the button state of a click form */
extern void formSetClickState(W_CLICKFORM *psForm, UDWORD state);
/* Run a form widget */
extern void formRun(W_FORM *psWidget, W_CONTEXT *psContext);
/* Respond to a mouse form up */
extern void formReleased(W_FORM *psWidget, UDWORD key, W_CONTEXT *psContext);
/* Respond to a mouse moving over a form */
extern void formHiLite(W_FORM *psWidget, W_CONTEXT *psContext);
/* Respond to the mouse moving off a form */
extern void formHiLiteLost(W_FORM *psWidget, W_CONTEXT *psContext);
/* 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);

View File

@ -119,24 +119,24 @@ void labelDisplay(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pC
}
/* Respond to a mouse moving over a label */
void labelHiLite(W_LABEL *psWidget, W_CONTEXT *psContext)
void W_LABEL::highlight(W_CONTEXT *psContext)
{
/* If there is a tip string start the tool tip */
if (psWidget->pTip)
if (pTip)
{
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, psContext->psScreen->TipFontID,
psContext->psForm->aColours,
x + psContext->xOffset, y + psContext->yOffset,
width, height);
}
}
/* Respond to the mouse moving off a label */
void labelHiLiteLost(W_LABEL *psWidget)
void W_LABEL::highlightLost(W_CONTEXT *)
{
if (psWidget->pTip)
if (pTip)
{
tipStop((WIDGET *)psWidget);
tipStop(this);
}
}

View File

@ -28,10 +28,14 @@
#include "widgbase.h"
#include "lib/ivis_opengl/textdraw.h"
struct W_LABEL : public WIDGET
{
W_LABEL(W_LABINIT const *init);
void highlight(W_CONTEXT *psContext);
void highlightLost(W_CONTEXT *);
char aText[WIDG_MAXSTR]; // Text on the label
enum iV_fonts FontID;
const char *pTip; // The tool tip for the button
@ -46,10 +50,4 @@ extern void labelFree(W_LABEL *psWidget);
/* label display function */
extern void labelDisplay(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
/* Respond to a mouse moving over a label */
extern void labelHiLite(W_LABEL *psWidget, W_CONTEXT *psContext);
/* Respond to the mouse moving off a label */
extern void labelHiLiteLost(W_LABEL *psWidget);
#endif // __INCLUDED_LIB_WIDGET_LABEL_H__

View File

@ -216,8 +216,9 @@ static void sliderGetBarBox(W_SLIDER *psSlider, SWORD *pX, SWORD *pY,
/* Run a slider widget */
void sliderRun(W_SLIDER *psWidget, W_CONTEXT *psContext)
void W_SLIDER::run(W_CONTEXT *psContext)
{
W_SLIDER *psWidget = this;
SDWORD mx, my;
UDWORD stopSize;
@ -228,7 +229,7 @@ void sliderRun(W_SLIDER *psWidget, W_CONTEXT *psContext)
}
else if (!(psWidget->state & SLD_DRAG) && mouseDown(MOUSE_LMB))
{
sliderClicked(psWidget, psContext);
clicked(psContext, WKEY_NONE);
}
if (psWidget->state & SLD_DRAG)
{
@ -317,8 +318,9 @@ void sliderRun(W_SLIDER *psWidget, W_CONTEXT *psContext)
/* Respond to a mouse click */
void sliderClicked(W_SLIDER *psWidget, W_CONTEXT *psContext)
void W_SLIDER::clicked(W_CONTEXT *psContext, WIDGET_KEY)
{
W_SLIDER *psWidget = this;
#if 0
SWORD x, y;
UWORD width, height;
@ -345,23 +347,22 @@ void sliderClicked(W_SLIDER *psWidget, W_CONTEXT *psContext)
/* Respond to a mouse up */
void sliderReleased(W_SLIDER *psWidget)
void W_SLIDER::released(W_CONTEXT *, WIDGET_KEY)
{
(void)psWidget;
}
/* Respond to a mouse moving over a slider */
void sliderHiLite(W_SLIDER *psWidget)
void W_SLIDER::highlight(W_CONTEXT *)
{
psWidget->state |= SLD_HILITE;
state |= SLD_HILITE;
}
/* Respond to the mouse moving off a slider */
void sliderHiLiteLost(W_SLIDER *psWidget)
void W_SLIDER::highlightLost(W_CONTEXT *)
{
psWidget->state &= ~SLD_HILITE;
state &= ~SLD_HILITE;
}
/* The slider display function */

View File

@ -31,17 +31,16 @@
#define SLD_DRAG 0x0001 // Slider is being dragged
#define SLD_HILITE 0x0002 // Slider is hilited
/* Respond to a mouse click */
void sliderClicked(struct W_SLIDER *psWidget, W_CONTEXT *psContext);
struct W_SLIDER : public WIDGET
{
W_SLIDER(W_SLDINIT const *init);
void clicked(W_CONTEXT *context, WIDGET_KEY)
{
sliderClicked(this, context);
}
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);
WSLD_ORIENTATION orientation; // The orientation of the slider
UWORD numStops; // Number of stop positions on the slider
@ -60,18 +59,6 @@ extern void sliderFree(W_SLIDER *psWidget);
/* Initialise a slider widget before running it */
extern void sliderInitialise(W_SLIDER *psWidget);
/* Run a slider widget */
extern void sliderRun(W_SLIDER *psWidget, W_CONTEXT *psContext);
/* Respond to a mouse up */
extern void sliderReleased(W_SLIDER *psWidget);
/* Respond to a mouse moving over a slider */
extern void sliderHiLite(W_SLIDER *psWidget);
/* Respond to the mouse moving off a slider */
extern void sliderHiLiteLost(W_SLIDER *psWidget);
/* The slider display function */
extern void sliderDisplay(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);

View File

@ -34,6 +34,11 @@ struct WIDGET;
struct W_CONTEXT;
struct W_FORM;
struct W_INIT;
struct W_SCREEN;
struct W_EDITBOX;
struct W_BARGRAPH;
struct W_BUTTON;
struct W_LABEL;
/* The display function prototype */
typedef void (*WIDGET_DISPLAY)(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
@ -69,6 +74,11 @@ struct WIDGET
virtual ~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 run(W_CONTEXT *) {}
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.
@ -85,13 +95,19 @@ struct WIDGET
};
struct WidgetTrigger
{
WIDGET *widget;
};
typedef std::vector<WidgetTrigger> WidgetTriggers;
/* The screen structure which stores all info for a widget screen */
struct W_SCREEN
{
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 *psRetWidget; ///< The widget to be returned by widgRunScreen
WidgetTriggers retWidgets; ///< The widgets to be returned by widgRunScreen.
};
/* Context information to pass into the widget functions */

View File

@ -43,22 +43,20 @@ static bool bWidgetsActive = true;
/* The widget the mouse is over this update */
static WIDGET *psMouseOverWidget = NULL;
static WIDGET_KEY pressed, released;
static WIDGET_AUDIOCALLBACK AudioCallback = NULL;
static SWORD HilightAudioID = -1;
static SWORD ClickedAudioID = -1;
/* Function prototypes */
void widgHiLite(WIDGET *psWidget, W_CONTEXT *psContext);
void widgHiLiteLost(WIDGET *psWidget, W_CONTEXT *psContext);
static void widgReleased(WIDGET *psWidget, UDWORD key, W_CONTEXT *psContext);
static void widgRun(WIDGET *psWidget, W_CONTEXT *psContext);
static void widgDisplayForm(W_FORM *psForm, UDWORD xOffset, UDWORD yOffset);
static void widgRelease(WIDGET *psWidget);
/* Buffer to return strings in */
static char aStringRetBuffer[WIDG_MAXSTR];
static WIDGET_KEY lastReleasedKey_DEPRECATED = WKEY_NONE;
/* Initialise the widget module */
bool widgInitialise()
{
@ -538,7 +536,7 @@ static bool widgDeleteFromForm(W_FORM *psForm, UDWORD id, W_CONTEXT *psContext)
/* Clear the last hilite if necessary */
if ((psForm->psLastHiLite != NULL) && (psForm->psLastHiLite->id == id))
{
widgHiLiteLost(psForm->psLastHiLite, psContext);
psForm->psLastHiLite->highlightLost(psContext);
psForm->psLastHiLite = NULL;
}
@ -907,20 +905,6 @@ void widgSetUserData2(W_SCREEN *psScreen, UDWORD id, UDWORD UserData)
}
/* Return the user data for the returned widget */
void *widgGetLastUserData(W_SCREEN *psScreen)
{
assert(psScreen != NULL);
if (psScreen->psRetWidget)
{
return psScreen->psRetWidget->pUserData;
}
return NULL;
}
/* Set tip string for a widget */
void widgSetTip(W_SCREEN *psScreen, UDWORD id, const char *pTip)
{
@ -982,17 +966,16 @@ void widgSetTipText(WIDGET *psWidget, const char *pTip)
}
/* Return which key was used to press the last returned widget */
UDWORD widgGetButtonKey(W_SCREEN *psScreen)
UDWORD widgGetButtonKey_DEPRECATED(W_SCREEN *psScreen)
{
/* Don't actually need the screen parameter at the moment - but it might be
handy if released needs to stop being a static and moves into
the screen structure */
(void)psScreen;
return released;
return lastReleasedKey_DEPRECATED;
}
/* Get a button or clickable form's state */
UDWORD widgGetButtonState(W_SCREEN *psScreen, UDWORD id)
{
@ -1275,17 +1258,13 @@ static void widgProcessCallbacks(W_CONTEXT *psContext)
static void widgProcessForm(W_CONTEXT *psContext)
{
WIDGET *psCurr, *psOver;
SDWORD mx, my, omx, omy, xOffset, yOffset, xOrigin, yOrigin;
SDWORD mx, my, xOffset, yOffset, xOrigin, yOrigin;
W_FORM *psForm;
W_CONTEXT sFormContext, sWidgContext;
/* Note current form */
psForm = psContext->psForm;
// if(psForm->disableChildren == true) {
// return;
// }
/* Note the current mouse position */
mx = psContext->mx;
my = psContext->my;
@ -1331,144 +1310,187 @@ static void widgProcessForm(W_CONTEXT *psContext)
else
{
/* Run the widget */
widgRun(psCurr, &sWidgContext);
psCurr->run(&sWidgContext);
}
}
/* Now check for mouse clicks */
omx = mx - xOrigin;
omy = my - yOrigin;
if (mx >= 0 && mx <= psForm->width &&
my >= 0 && my <= psForm->height)
{
/* Update for the origin */
/* Mouse is over the form - is it over any of the widgets */
for (psCurr = formGetWidgets(psForm); psCurr; psCurr = psCurr->psNext)
{
/* Skip any hidden widgets */
if (psCurr->style & WIDG_HIDDEN)
{
continue;
}
if (omx >= psCurr->x &&
omy >= psCurr->y &&
omx <= psCurr->x + psCurr->width &&
omy <= psCurr->y + psCurr->height)
{
/* Note the widget the mouse is over */
if (!psMouseOverWidget)
{
psMouseOverWidget = (WIDGET *)psCurr;
}
psOver = psCurr;
/* Don't check the widgets if it is a clickable form */
if (!(psForm->style & WFORM_CLICKABLE))
{
if (pressed != WKEY_NONE && psCurr->type != WIDG_FORM)
{
/* Tell the widget it has been clicked */
psCurr->clicked(&sWidgContext, pressed);
}
if (released != WKEY_NONE && psCurr->type != WIDG_FORM)
{
/* Tell the widget the mouse button has gone up */
widgReleased(psCurr, released, &sWidgContext);
}
}
}
}
/* Note that the mouse is over this form */
if (!psMouseOverWidget)
{
psMouseOverWidget = (WIDGET *)psForm;
}
/* Only send the Clicked or Released messages if a widget didn't get the message */
if (pressed != WKEY_NONE &&
(psOver == NULL || (psForm->style & WFORM_CLICKABLE)))
{
/* Tell the form it has been clicked */
psForm->clicked(psContext, pressed);
}
if (released != WKEY_NONE &&
(psOver == NULL || (psForm->style & WFORM_CLICKABLE)))
{
/* Tell the form the mouse button has gone up */
widgReleased((WIDGET *)psForm, released, psContext);
}
}
/* See if the mouse has moved onto or off a widget */
if (psForm->psLastHiLite != psOver)
{
if (psOver != NULL)
{
widgHiLite(psOver, &sWidgContext);
}
if (psForm->psLastHiLite != NULL)
{
widgHiLiteLost(psForm->psLastHiLite, &sWidgContext);
}
psForm->psLastHiLite = psOver;
}
/* Run this form */
widgRun((WIDGET *)psForm, psContext);
psForm->run(psContext);
}
static void widgProcessClick(W_CONTEXT &psContext, WIDGET_KEY key, bool wasPressed)
{
W_FORM *psForm = psContext.psForm;
Vector2i origin;
formGetOrigin(psForm, &origin.x, &origin.y);
Vector2i pos(psContext.mx, psContext.my);
Vector2i oPos = pos - origin;
Vector2i offset(psContext.xOffset, psContext.yOffset);
Vector2i oOffset = offset + origin;
// Process subforms (but not widgets, yet).
for (WIDGET *psCurr = formGetWidgets(psForm); psCurr; psCurr = psCurr->psNext)
{
if ((psCurr->style & WIDG_HIDDEN) != 0 || psCurr->type != WIDG_FORM)
{
continue; // Skip any hidden forms or non-form widgets.
}
// Found a sub form, so set up the context.
W_CONTEXT sFormContext;
sFormContext.psScreen = psContext.psScreen;
sFormContext.psForm = (W_FORM *)psCurr;
sFormContext.mx = oPos.x - psCurr->x;
sFormContext.my = oPos.y - psCurr->y;
sFormContext.xOffset = oOffset.x + psCurr->x;
sFormContext.yOffset = oOffset.y + psCurr->y;
// Process it (recursively).
widgProcessClick(sFormContext, key, wasPressed);
}
if (pos.x < 0 || pos.x > psForm->width || pos.y < 0 || pos.y >= psForm->height)
{
return; // Click is somewhere else.
}
W_CONTEXT sWidgContext;
sWidgContext.psScreen = psContext.psScreen;
sWidgContext.psForm = psForm;
sWidgContext.mx = oPos.x;
sWidgContext.my = oPos.y;
sWidgContext.xOffset = oOffset.x;
sWidgContext.yOffset = oOffset.y;
// Process widgets.
WIDGET *widgetUnderMouse = NULL;
for (WIDGET *psCurr = formGetWidgets(psForm); psCurr; psCurr = psCurr->psNext)
{
if (psCurr->style & WIDG_HIDDEN)
{
continue; // Skip hidden widgets.
}
if (oPos.x < psCurr->x || oPos.x > psCurr->x + psCurr->width || oPos.y < psCurr->y || oPos.y > psCurr->y + psCurr->height)
{
continue; // The click missed the widget.
}
if (!psMouseOverWidget)
{
psMouseOverWidget = psCurr; // Mark that the mouse is over a widget (if we haven't already).
}
if ((psForm->style & WFORM_CLICKABLE) != 0)
{
continue; // Don't check the widgets if we are a clickable form.
}
widgetUnderMouse = psCurr; // One (at least) of our widgets will get the click, so don't send it to us (we are the form).
if (key == WKEY_NONE)
{
continue; // Just checking mouse position, not a click.
}
if (wasPressed)
{
psCurr->clicked(&sWidgContext, key);
}
else
{
psCurr->released(&sWidgContext, key);
}
}
// See if the mouse has moved onto or off a widget.
if (psForm->psLastHiLite != widgetUnderMouse)
{
if (psForm->psLastHiLite != NULL)
{
psForm->psLastHiLite->highlightLost(&sWidgContext);
}
if (widgetUnderMouse != NULL)
{
widgetUnderMouse->highlight(&sWidgContext);
}
psForm->psLastHiLite = widgetUnderMouse;
}
if (widgetUnderMouse != NULL)
{
return; // Only send the Clicked or Released messages if a widget didn't get the message.
}
if (!psMouseOverWidget)
{
psMouseOverWidget = psForm; // Note that the mouse is over this form.
}
if (key == WKEY_NONE)
{
return; // Just checking mouse position, not a click.
}
if (wasPressed)
{
psForm->clicked(&psContext, key);
}
else
{
psForm->released(&psContext, key);
}
}
/* Execute a set of widgets for one cycle.
* Return the id of the widget that was activated, or 0 for none.
* Returns a list of activated widgets.
*/
UDWORD widgRunScreen(W_SCREEN *psScreen)
WidgetTriggers const &widgRunScreen(W_SCREEN *psScreen)
{
W_CONTEXT sContext;
psScreen->retWidgets.clear();
psScreen->psRetWidget = NULL;
// Note which keys have been pressed
pressed = WKEY_NONE;
sContext.mx = mouseX();
sContext.my = mouseY();
if (getWidgetsStatus())
{
if (mousePressed(MOUSE_LMB))
{
pressed = WKEY_PRIMARY;
sContext.mx = mousePressPos(MOUSE_LMB).x;
sContext.my = mousePressPos(MOUSE_LMB).y;
}
else if (mousePressed(MOUSE_RMB))
{
pressed = WKEY_SECONDARY;
sContext.mx = mousePressPos(MOUSE_RMB).x;
sContext.my = mousePressPos(MOUSE_RMB).y;
}
released = WKEY_NONE;
if (mouseReleased(MOUSE_LMB))
{
released = WKEY_PRIMARY;
sContext.mx = mouseReleasePos(MOUSE_LMB).x;
sContext.my = mouseReleasePos(MOUSE_LMB).y;
}
else if (mouseReleased(MOUSE_RMB))
{
released = WKEY_SECONDARY;
sContext.mx = mouseReleasePos(MOUSE_RMB).x;
sContext.my = mouseReleasePos(MOUSE_RMB).y;
}
}
/* Initialise the context */
W_CONTEXT sContext;
sContext.psScreen = psScreen;
sContext.psForm = (W_FORM *)psScreen->psForm;
sContext.psForm = psScreen->psForm;
sContext.xOffset = 0;
sContext.yOffset = 0;
psMouseOverWidget = NULL;
// Note which keys have been pressed
lastReleasedKey_DEPRECATED = WKEY_NONE;
if (getWidgetsStatus())
{
MousePresses const &clicks = inputGetClicks();
for (MousePresses::const_iterator c = clicks.begin(); c != clicks.end(); ++c)
{
WIDGET_KEY wkey;
switch (c->key)
{
case MOUSE_LMB: wkey = WKEY_PRIMARY; break;
case MOUSE_RMB: wkey = WKEY_SECONDARY; break;
default: continue; // Who cares about other mouse buttons?
}
bool pressed;
switch (c->action)
{
case MousePress::Press: pressed = true; break;
case MousePress::Release: pressed = false; break;
default: continue;
}
sContext.mx = c->pos.x;
sContext.my = c->pos.y;
widgProcessClick(sContext, wkey, pressed);
lastReleasedKey_DEPRECATED = wkey;
}
}
sContext.mx = mouseX();
sContext.my = mouseY();
widgProcessClick(sContext, WKEY_NONE, true); // Update highlights and psMouseOverWidget.
/* Process the screen's widgets */
widgProcessForm(&sContext);
@ -1476,14 +1498,16 @@ UDWORD widgRunScreen(W_SCREEN *psScreen)
widgProcessCallbacks(&sContext);
/* Return the ID of a pressed button or finished edit box if any */
return psScreen->psRetWidget ? psScreen->psRetWidget->id : 0;
return psScreen->retWidgets;
}
/* Set the id number for widgRunScreen to return */
void widgSetReturn(W_SCREEN *psScreen, WIDGET *psWidget)
{
psScreen->psRetWidget = psWidget;
WidgetTrigger trigger;
trigger.widget = psWidget;
psScreen->retWidgets.push_back(trigger);
}
@ -1553,37 +1577,10 @@ void widgDisplayScreen(W_SCREEN *psScreen)
tipDisplay();
}
/* Call the correct function for loss of focus */
static void widgFocusLost(W_SCREEN *psScreen, WIDGET *psWidget)
{
switch (psWidget->type)
{
case WIDG_FORM:
break;
case WIDG_LABEL:
break;
case WIDG_BUTTON:
break;
case WIDG_EDITBOX:
((W_EDITBOX *)psWidget)->focusLost(psScreen);
break;
case WIDG_BARGRAPH:
break;
case WIDG_SLIDER:
break;
default:
ASSERT(!"Unknown widget type", "Unknown widget type");
break;
}
}
/* Set the keyboard focus for the screen */
void screenSetFocus(W_SCREEN *psScreen, WIDGET *psWidget)
{
if (psScreen->psFocus != NULL)
{
widgFocusLost(psScreen, psScreen->psFocus);
}
screenClearFocus(psScreen);
psScreen->psFocus = psWidget;
}
@ -1593,128 +1590,11 @@ void screenClearFocus(W_SCREEN *psScreen)
{
if (psScreen->psFocus != NULL)
{
widgFocusLost(psScreen, psScreen->psFocus);
psScreen->psFocus->focusLost(psScreen);
psScreen->psFocus = NULL;
}
}
/* Call the correct function for mouse over */
void widgHiLite(WIDGET *psWidget, W_CONTEXT *psContext)
{
(void)psContext;
switch (psWidget->type)
{
case WIDG_FORM:
formHiLite((W_FORM *)psWidget, psContext);
break;
case WIDG_LABEL:
labelHiLite((W_LABEL *)psWidget, psContext);
break;
case WIDG_BUTTON:
buttonHiLite((W_BUTTON *)psWidget, psContext);
break;
case WIDG_EDITBOX:
editBoxHiLite((W_EDITBOX *)psWidget);
break;
case WIDG_BARGRAPH:
barGraphHiLite((W_BARGRAPH *)psWidget, psContext);
break;
case WIDG_SLIDER:
sliderHiLite((W_SLIDER *)psWidget);
break;
default:
ASSERT(!"Unknown widget type", "Unknown widget type");
break;
}
}
/* Call the correct function for mouse moving off */
void widgHiLiteLost(WIDGET *psWidget, W_CONTEXT *psContext)
{
(void)psContext;
switch (psWidget->type)
{
case WIDG_FORM:
formHiLiteLost((W_FORM *)psWidget, psContext);
break;
case WIDG_LABEL:
labelHiLiteLost((W_LABEL *)psWidget);
break;
case WIDG_BUTTON:
buttonHiLiteLost((W_BUTTON *)psWidget);
break;
case WIDG_EDITBOX:
editBoxHiLiteLost((W_EDITBOX *)psWidget);
break;
case WIDG_BARGRAPH:
barGraphHiLiteLost((W_BARGRAPH *)psWidget);
break;
case WIDG_SLIDER:
sliderHiLiteLost((W_SLIDER *)psWidget);
break;
default:
ASSERT(!"Unknown widget type", "Unknown widget type");
break;
}
}
/* Call the correct function for mouse released */
static void widgReleased(WIDGET *psWidget, UDWORD key, W_CONTEXT *psContext)
{
switch (psWidget->type)
{
case WIDG_FORM:
formReleased((W_FORM *)psWidget, key, psContext);
break;
case WIDG_LABEL:
break;
case WIDG_BUTTON:
buttonReleased(psContext->psScreen, (W_BUTTON *)psWidget, key);
break;
case WIDG_EDITBOX:
break;
case WIDG_BARGRAPH:
break;
case WIDG_SLIDER:
sliderReleased((W_SLIDER *)psWidget);
break;
default:
ASSERT(!"Unknown widget type", "Unknown widget type");
break;
}
}
/* Call the correct function to run a widget */
static void widgRun(WIDGET *psWidget, W_CONTEXT *psContext)
{
switch (psWidget->type)
{
case WIDG_FORM:
formRun((W_FORM *)psWidget, psContext);
break;
case WIDG_LABEL:
break;
case WIDG_BUTTON:
buttonRun((W_BUTTON *)psWidget);
break;
case WIDG_EDITBOX:
((W_EDITBOX *)psWidget)->run(psContext);
break;
case WIDG_BARGRAPH:
break;
case WIDG_SLIDER:
sliderRun((W_SLIDER *)psWidget, psContext);
break;
default:
ASSERT(!"Unknown widget type", "Unknown widget type");
break;
}
}
void WidgSetAudio(WIDGET_AUDIOCALLBACK Callback, SWORD HilightID, SWORD ClickedID)
{
AudioCallback = Callback;

View File

@ -357,9 +357,6 @@ extern UDWORD widgGetUserData2(W_SCREEN *psScreen, UDWORD id);
/** Set the user data for a widget */
extern void widgSetUserData2(W_SCREEN *psScreen, UDWORD id, UDWORD UserData);
/** Return the user data for the returned widget */
extern void *widgGetLastUserData(W_SCREEN *psScreen);
/** Get widget structure */
extern WIDGET *widgGetFromID(W_SCREEN *psScreen, UDWORD id);
@ -405,7 +402,7 @@ extern void widgSetButtonState(W_SCREEN *psScreen, UDWORD id, UDWORD state);
/** Return which key was used to press the last returned widget */
extern UDWORD widgGetButtonKey(W_SCREEN *psScreen);
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.
@ -422,7 +419,7 @@ 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.
*/
extern UDWORD widgRunScreen(W_SCREEN *psScreen);
WidgetTriggers const &widgRunScreen(W_SCREEN *psScreen);
/** Display the screen's widgets in their current state
* (Call after calling widgRunScreen, this allows the input

View File

@ -33,12 +33,6 @@ extern void widgSetReturn(W_SCREEN *psScreen, WIDGET *psWidget);
/* Release a list of widgets */
extern void widgReleaseWidgetList(WIDGET *psWidgets);
/* Call the correct function for mouse over */
extern void widgHiLite(WIDGET *psWidget, W_CONTEXT *psContext);
/* Call the correct function for mouse moving off */
extern void widgHiLiteLost(WIDGET *psWidget, W_CONTEXT *psContext);
/* Set the keyboard focus for the screen */
extern void screenSetFocus(W_SCREEN *psScreen, WIDGET *psWidget);

View File

@ -1,11 +1,11 @@
#!/bin/sh
VerLib="1.5.13"
VerLib="1.5.14"
OutDir="libpng"
DirectorY="${OutDir}-${VerLib}"
FileName="${DirectorY}.tar.gz"
SourceDLP="http://downloads.sourceforge.net/project/libpng/libpng15/${VerLib}/${FileName}"
MD5Sum="9c5a584d4eb5fe40d0f1bc2090112c65"
MD5Sum="27e76e0223d654093ffeb2f3daa56cc3"
configs/FetchSource.sh "${DirectorY}" "${OutDir}" "${FileName}" "${SourceDLP}" "${MD5Sum}"
exit ${?}

View File

@ -348,30 +348,32 @@ bool closeChallenges()
// slot was selected otherwise cancel was selected..
bool runChallenges(void)
{
UDWORD id = 0;
id = widgRunScreen(psRequestScreen);
sstrcpy(sRequestResult, ""); // set returned filename to null;
// cancel this operation...
if (id == CHALLENGE_CANCEL || CancelPressed())
WidgetTriggers const &triggers = widgRunScreen(psRequestScreen);
for (WidgetTriggers::const_iterator trigger = triggers.begin(); trigger != triggers.end(); ++trigger)
{
goto failure;
}
unsigned id = trigger->widget->id;
// clicked a load entry
if (id >= CHALLENGE_ENTRY_START && id <= CHALLENGE_ENTRY_END)
{
if (((W_BUTTON *)widgGetFromID(psRequestScreen, id))->pText)
sstrcpy(sRequestResult, ""); // set returned filename to null;
// cancel this operation...
if (id == CHALLENGE_CANCEL || CancelPressed())
{
sstrcpy(sRequestResult, (const char *)((W_BUTTON *)widgGetFromID(psRequestScreen, id))->pUserData);
goto failure;
}
else
// clicked a load entry
if (id >= CHALLENGE_ENTRY_START && id <= CHALLENGE_ENTRY_END)
{
goto failure; // clicked on an empty box
if (((W_BUTTON *)widgGetFromID(psRequestScreen, id))->pText)
{
sstrcpy(sRequestResult, (const char *)((W_BUTTON *)widgGetFromID(psRequestScreen, id))->pUserData);
}
else
{
goto failure; // clicked on an empty box
}
goto success;
}
goto success;
}
return false;

View File

@ -345,13 +345,13 @@ void ProcessRadarInput()
{
if (mousePressed(MOUSE_ORDER))
{
x = mousePressPos(MOUSE_ORDER).x;
y = mousePressPos(MOUSE_ORDER).y;
x = mousePressPos_DEPRECATED(MOUSE_ORDER).x;
y = mousePressPos_DEPRECATED(MOUSE_ORDER).y;
}
else
{
x = mousePressPos(MOUSE_MMB).x;
y = mousePressPos(MOUSE_MMB).y;
x = mousePressPos_DEPRECATED(MOUSE_MMB).x;
y = mousePressPos_DEPRECATED(MOUSE_MMB).y;
}
if(driveModeActive()) {
driveProcessRadarInput(x,y);
@ -386,8 +386,8 @@ void ProcessRadarInput()
}
else if (mousePressed(MOUSE_SELECT))
{
x = mousePressPos(MOUSE_SELECT).x;
y = mousePressPos(MOUSE_SELECT).y;
x = mousePressPos_DEPRECATED(MOUSE_SELECT).x;
y = mousePressPos_DEPRECATED(MOUSE_SELECT).y;
CalcRadarPosition(x, y, &PosX, &PosY);

View File

@ -149,9 +149,8 @@ static void runHyperlink(void)
bool runTitleMenu(void)
{
UDWORD id;
id = widgRunScreen(psWScreen); // Run the current set of widgets
WidgetTriggers const &triggers = widgRunScreen(psWScreen);
unsigned id = triggers.empty()? 0 : triggers.front().widget->id; // Just use first click here, since the next click could be on another menu.
switch(id)
{
@ -206,9 +205,9 @@ static bool startTutorialMenu(void)
bool runTutorialMenu(void)
{
UDWORD id;
WidgetTriggers const &triggers = widgRunScreen(psWScreen);
unsigned id = triggers.empty()? 0 : triggers.front().widget->id; // Just use first click here, since the next click could be on another menu.
id = widgRunScreen(psWScreen); // Run the current set of widgets
switch(id)
{
case FRONTEND_TUTORIAL:
@ -396,7 +395,8 @@ static void SPinit(void)
bool runCampaignSelector()
{
int id = widgRunScreen(psWScreen);
WidgetTriggers const &triggers = widgRunScreen(psWScreen);
unsigned id = triggers.empty()? 0 : triggers.front().widget->id; // Just use first click here, since the next click could be on another menu.
if (id == FRONTEND_QUIT)
{
changeTitleMode(SINGLE); // go back
@ -412,8 +412,6 @@ bool runCampaignSelector()
bool runSinglePlayerMenu(void)
{
UDWORD id;
if(bLoadSaveUp)
{
if(runLoadSave(false))// check for file name.
@ -427,7 +425,8 @@ bool runSinglePlayerMenu(void)
}
else
{
id = widgRunScreen(psWScreen); // Run the current set of widgets
WidgetTriggers const &triggers = widgRunScreen(psWScreen);
unsigned id = triggers.empty()? 0 : triggers.front().widget->id; // Just use first click here, since the next click could be on another menu.
switch(id)
{
@ -512,9 +511,9 @@ static bool startMultiPlayerMenu(void)
bool runMultiPlayerMenu(void)
{
UDWORD id;
WidgetTriggers const &triggers = widgRunScreen(psWScreen);
unsigned id = triggers.empty()? 0 : triggers.front().widget->id; // Just use first click here, since the next click could be on another menu.
id = widgRunScreen(psWScreen); // Run the current set of widgets
switch(id)
{
case FRONTEND_HOST:
@ -581,9 +580,9 @@ static bool startOptionsMenu(void)
bool runOptionsMenu(void)
{
UDWORD id;
WidgetTriggers const &triggers = widgRunScreen(psWScreen);
unsigned id = triggers.empty()? 0 : triggers.front().widget->id; // Just use first click here, since the next click could be on another menu.
id = widgRunScreen(psWScreen); // Run the current set of widgets
switch(id)
{
case FRONTEND_GAMEOPTIONS:
@ -722,10 +721,10 @@ static bool startGraphicsOptionsMenu(void)
bool runGraphicsOptionsMenu(void)
{
UDWORD id;
int mode = 0;
WidgetTriggers const &triggers = widgRunScreen(psWScreen);
unsigned id = triggers.empty()? 0 : triggers.front().widget->id; // Just use first click here, since the next click could be on another menu.
id = widgRunScreen(psWScreen); // Run the current set of widgets
switch(id)
{
case FRONTEND_SSHAKE:
@ -872,9 +871,9 @@ static bool startAudioOptionsMenu(void)
bool runAudioOptionsMenu(void)
{
UDWORD id;
WidgetTriggers const &triggers = widgRunScreen(psWScreen);
unsigned id = triggers.empty()? 0 : triggers.front().widget->id; // Just use first click here, since the next click could be on another menu.
id = widgRunScreen(psWScreen); // Run the current set of widgets
switch(id)
{
case FRONTEND_FX:
@ -1015,7 +1014,9 @@ static bool startVideoOptionsMenu(void)
bool runVideoOptionsMenu(void)
{
QList<QSize> modes = wzAvailableResolutions();
UDWORD id = widgRunScreen(psWScreen);
WidgetTriggers const &triggers = widgRunScreen(psWScreen);
unsigned id = triggers.empty()? 0 : triggers.front().widget->id; // Just use first click here, since the next click could be on another menu.
int level;
switch (id)
@ -1271,7 +1272,8 @@ static bool startMouseOptionsMenu(void)
bool runMouseOptionsMenu(void)
{
UDWORD id = widgRunScreen(psWScreen);
WidgetTriggers const &triggers = widgRunScreen(psWScreen);
unsigned id = triggers.empty()? 0 : triggers.front().widget->id; // Just use first click here, since the next click could be on another menu.
switch (id)
{
@ -1428,9 +1430,9 @@ static bool startGameOptionsMenu(void)
bool runGameOptionsMenu(void)
{
UDWORD id;
WidgetTriggers const &triggers = widgRunScreen(psWScreen);
unsigned id = triggers.empty()? 0 : triggers.front().widget->id; // Just use first click here, since the next click could be on another menu.
id = widgRunScreen(psWScreen); // Run the current set of widgets
switch(id)
{
case FRONTEND_LANGUAGE_R:

View File

@ -1115,8 +1115,6 @@ static void intProcessEditStats(UDWORD id)
/* Run the widgets for the in game interface */
INT_RETVAL intRunWidgets(void)
{
UDWORD retID;
INT_RETVAL retCode;
bool quitting = false;
UDWORD structX, structY, structX2, structY2;
@ -1234,27 +1232,28 @@ INT_RETVAL intRunWidgets(void)
}
/* Run the current set of widgets */
if (!bLoadSaveUp)
std::vector<unsigned> retIDs;
if(!bLoadSaveUp)
{
retID = widgRunScreen(psWScreen);
}
else
{
retID = 0;
WidgetTriggers const &triggers = widgRunScreen(psWScreen);
for (WidgetTriggers::const_iterator trigger = triggers.begin(); trigger != triggers.end(); ++trigger)
{
retIDs.push_back(trigger->widget->id);
}
}
/* We may need to trigger widgets with a key press */
if (keyButtonMapping)
{
/* Set the appropriate id */
retID = keyButtonMapping;
retIDs.push_back(keyButtonMapping);
/* Clear it so it doesn't trigger next time around */
keyButtonMapping = 0;
}
intLastWidget = retID;
if (bInTutorial && retID != 0)
intLastWidget = retIDs.empty()? 0 : retIDs.back();
if (bInTutorial && !retIDs.empty())
{
eventFireCallbackTrigger((TRIGGER_TYPE)CALL_BUTTON_PRESSED);
}
@ -1280,12 +1279,6 @@ INT_RETVAL intRunWidgets(void)
intRunMultiMenu();
}
if (retID >= IDPROX_START && retID <= IDPROX_END)
{
processProximityButtons(retID);
return INT_NONE;
}
/* Extra code for the design screen to deal with the shadow bar graphs */
if (intMode == INT_DESIGN)
{
@ -1293,160 +1286,168 @@ INT_RETVAL intRunWidgets(void)
intRunDesign();
}
/* Deal with any clicks */
switch (retID)
// Deal with any clicks.
for (std::vector<unsigned>::const_iterator rit = retIDs.begin(); rit != retIDs.end(); ++rit)
{
case 0:
/* default return value */
break;
/***************** Reticule buttons *****************/
unsigned retID = *rit;
case IDRET_OPTIONS:
intResetScreen(false);
(void)intAddOptions();
intMode = INT_OPTION;
break;
case IDRET_COMMAND:
intResetScreen(false);
widgSetButtonState(psWScreen, IDRET_COMMAND, WBUT_CLICKLOCK);
intAddCommand(NULL);
break;
case IDRET_BUILD:
intResetScreen(true);
widgSetButtonState(psWScreen, IDRET_BUILD, WBUT_CLICKLOCK);
intAddBuild(NULL);
break;
case IDRET_MANUFACTURE:
intResetScreen(true);
widgSetButtonState(psWScreen, IDRET_MANUFACTURE, WBUT_CLICKLOCK);
intAddManufacture(NULL);
break;
case IDRET_RESEARCH:
intResetScreen(true);
widgSetButtonState(psWScreen, IDRET_RESEARCH, WBUT_CLICKLOCK);
(void)intAddResearch(NULL);
break;
case IDRET_INTEL_MAP:
// check if RMB was clicked
if (widgGetButtonKey(psWScreen) & WKEY_SECONDARY)
if (retID >= IDPROX_START && retID <= IDPROX_END)
{
//set the current message to be the last non-proximity message added
setCurrentMsg();
setMessageImmediate(true);
processProximityButtons(retID);
return INT_NONE;
}
else
switch (retID)
{
/***************** Reticule buttons *****************/
case IDRET_OPTIONS:
intResetScreen(false);
(void)intAddOptions();
intMode = INT_OPTION;
break;
case IDRET_COMMAND:
intResetScreen(false);
widgSetButtonState(psWScreen, IDRET_COMMAND, WBUT_CLICKLOCK);
intAddCommand(NULL);
break;
case IDRET_BUILD:
intResetScreen(true);
widgSetButtonState(psWScreen, IDRET_BUILD, WBUT_CLICKLOCK);
intAddBuild(NULL);
break;
case IDRET_MANUFACTURE:
intResetScreen(true);
widgSetButtonState(psWScreen, IDRET_MANUFACTURE, WBUT_CLICKLOCK);
intAddManufacture(NULL);
break;
case IDRET_RESEARCH:
intResetScreen(true);
widgSetButtonState(psWScreen, IDRET_RESEARCH, WBUT_CLICKLOCK);
(void)intAddResearch(NULL);
break;
case IDRET_INTEL_MAP:
// check if RMB was clicked
if (widgGetButtonKey_DEPRECATED(psWScreen) == WKEY_SECONDARY)
{
//set the current message to be the last non-proximity message added
setCurrentMsg();
setMessageImmediate(true);
}
else
{
psCurrentMsg = NULL;
}
addIntelScreen();
break;
case IDRET_DESIGN:
intResetScreen(true);
widgSetButtonState(psWScreen, IDRET_DESIGN, WBUT_CLICKLOCK);
/*add the power bar - for looks! */
intShowPowerBar();
intAddDesign(false);
intMode = INT_DESIGN;
break;
case IDRET_CANCEL:
intResetScreen(false);
psCurrentMsg = NULL;
}
addIntelScreen();
break;
case IDRET_DESIGN:
intResetScreen(true);
widgSetButtonState(psWScreen, IDRET_DESIGN, WBUT_CLICKLOCK);
/*add the power bar - for looks! */
intShowPowerBar();
(void)intAddDesign(false);
intMode = INT_DESIGN;
break;
case IDRET_CANCEL:
intResetScreen(false);
psCurrentMsg = NULL;
break;
break;
/*Transporter button pressed - OFFWORLD Mission Maps ONLY *********/
case IDTRANTIMER_BUTTON:
addTransporterInterface(NULL, true);
break;
case IDTRANTIMER_BUTTON:
addTransporterInterface(NULL, true);
break;
case IDTRANS_LAUNCH:
processLaunchTransporter();
break;
case IDTRANS_LAUNCH:
processLaunchTransporter();
break;
/* Catch the quit button here */
case INTINGAMEOP_POPUP_QUIT:
case IDMISSIONRES_QUIT: // mission quit
case INTINGAMEOP_QUIT_CONFIRM: // esc quit confrim
case IDOPT_QUIT: // options screen quit
intResetScreen(false);
quitting = true;
break;
case INTINGAMEOP_POPUP_QUIT:
case IDMISSIONRES_QUIT: // mission quit
case INTINGAMEOP_QUIT_CONFIRM: // esc quit confrim
case IDOPT_QUIT: // options screen quit
intResetScreen(false);
quitting = true;
break;
// Process form tab clicks.
case IDOBJ_TABFORM: // If tab clicked on in object screen then refresh all rendered buttons.
RefreshObjectButtons();
RefreshTopicButtons();
break;
case IDOBJ_TABFORM: // If tab clicked on in object screen then refresh all rendered buttons.
RefreshObjectButtons();
RefreshTopicButtons();
break;
case IDSTAT_TABFORM: // If tab clicked on in stats screen then refresh all rendered buttons.
RefreshStatsButtons();
break;
case IDSTAT_TABFORM: // If tab clicked on in stats screen then refresh all rendered buttons.
RefreshStatsButtons();
break;
case IDDES_TEMPLFORM: // If tab clicked on in design template screen then refresh all rendered buttons.
RefreshStatsButtons();
break;
case IDDES_TEMPLFORM: // If tab clicked on in design template screen then refresh all rendered buttons.
RefreshStatsButtons();
break;
case IDDES_COMPFORM: // If tab clicked on in design component screen then refresh all rendered buttons.
RefreshObjectButtons();
RefreshSystem0Buttons();
break;
case IDDES_COMPFORM: // If tab clicked on in design component screen then refresh all rendered buttons.
RefreshObjectButtons();
RefreshSystem0Buttons();
break;
/* Default case passes remaining IDs to appropriate function */
default:
switch (intMode)
{
case INT_OPTION:
intProcessOptions(retID);
break;
case INT_EDITSTAT:
intProcessEditStats(retID);
break;
case INT_STAT:
case INT_CMDORDER:
/* In stat mode ids get passed to processObject
* and then through to processStats
*/
// NO BREAK HERE! THIS IS CORRECT;
case INT_OBJECT:
intProcessObject(retID);
break;
case INT_ORDER:
intProcessOrder(retID);
break;
case INT_MISSIONRES:
intProcessMissionResult(retID);
break;
case INT_INGAMEOP:
intProcessInGameOptions(retID);
break;
case INT_MULTIMENU:
intProcessMultiMenu(retID);
break;
case INT_DESIGN:
intProcessDesign(retID);
break;
case INT_INTELMAP:
intProcessIntelMap(retID);
break;
case INT_TRANSPORTER:
intProcessTransporter(retID);
break;
case INT_NORMAL:
break;
/* Default case passes remaining IDs to appropriate function */
default:
ASSERT(false, "intRunWidgets: unknown interface mode");
switch (intMode)
{
case INT_OPTION:
intProcessOptions(retID);
break;
case INT_EDITSTAT:
intProcessEditStats(retID);
break;
case INT_STAT:
case INT_CMDORDER:
/* In stat mode ids get passed to processObject
* and then through to processStats
*/
// NO BREAK HERE! THIS IS CORRECT;
case INT_OBJECT:
intProcessObject(retID);
break;
case INT_ORDER:
intProcessOrder(retID);
break;
case INT_MISSIONRES:
intProcessMissionResult(retID);
break;
case INT_INGAMEOP:
intProcessInGameOptions(retID);
break;
case INT_MULTIMENU:
intProcessMultiMenu(retID);
break;
case INT_DESIGN:
intProcessDesign(retID);
break;
case INT_INTELMAP:
intProcessIntelMap(retID);
break;
case INT_TRANSPORTER:
intProcessTransporter(retID);
break;
case INT_NORMAL:
break;
default:
ASSERT(false, "intRunWidgets: unknown interface mode");
break;
}
break;
}
break;
}
if (!quitting && !retID)
if (!quitting && retIDs.empty())
{
if ((intMode == INT_OBJECT || intMode == INT_STAT) && objMode == IOBJ_BUILDSEL)
{
@ -1672,7 +1673,7 @@ INT_RETVAL intRunWidgets(void)
{
retCode = INT_QUIT;
}
else if (retID || intMode == INT_EDIT || intMode == INT_MISSIONRES || widgOverID != 0)
else if (!retIDs.empty() || intMode == INT_EDIT || intMode == INT_MISSIONRES || widgOverID != 0)
{
retCode = INT_INTERCEPT;
}
@ -2006,7 +2007,7 @@ static void intProcessObject(UDWORD id)
else if (id >= IDOBJ_OBJSTART && id <= IDOBJ_OBJEND)
{
/* deal with RMB clicks */
if (widgGetButtonKey(psWScreen) & WKEY_SECONDARY)
if (widgGetButtonKey_DEPRECATED(psWScreen) == WKEY_SECONDARY)
{
intObjectRMBPressed(id);
}
@ -2086,7 +2087,7 @@ static void intProcessObject(UDWORD id)
id <= IDOBJ_STATEND)
{
/* deal with RMB clicks */
if (widgGetButtonKey(psWScreen) & WKEY_SECONDARY)
if (widgGetButtonKey_DEPRECATED(psWScreen) == WKEY_SECONDARY)
{
intObjStatRMBPressed(id);
}
@ -2163,7 +2164,7 @@ static void intProcessStats(UDWORD id)
"intProcessStructure: Invalid structure stats id");
/* deal with RMB clicks */
if (widgGetButtonKey(psWScreen) & WKEY_SECONDARY)
if (widgGetButtonKey_DEPRECATED(psWScreen) == WKEY_SECONDARY)
{
intStatsRMBPressed(id);
}
@ -2344,12 +2345,12 @@ static void intProcessStats(UDWORD id)
if (psStruct)
{
//LMB pressed
if (widgGetButtonKey(psWScreen) & WKEY_PRIMARY)
if (widgGetButtonKey_DEPRECATED(psWScreen) == WKEY_PRIMARY)
{
factoryLoopAdjust(psStruct, true);
}
//RMB pressed
else if (widgGetButtonKey(psWScreen) & WKEY_SECONDARY)
else if (widgGetButtonKey_DEPRECATED(psWScreen) == WKEY_SECONDARY)
{
factoryLoopAdjust(psStruct, false);
}
@ -3155,7 +3156,6 @@ static bool intAddObjectWindow(BASE_OBJECT *psObjects, BASE_OBJECT *psSelected,
SDWORD BufferID;
DROID *Droid;
STRUCTURE *Structure;
bool IsFactory;
int compIndex;
// Is the form already up?
@ -3421,6 +3421,13 @@ static bool intAddObjectWindow(BASE_OBJECT *psObjects, BASE_OBJECT *psSelected,
sLabInitCmdExp.height = 16;
sLabInitCmdExp.pText = "@@@@@ - overrun";
W_LABINIT sAllyResearch;
sAllyResearch.id = IDOBJ_ALLYRESEARCHSTART;
sAllyResearch.width = iV_GetImageWidth(IntImages, IMAGE_ALLY_RESEARCH);
sAllyResearch.height = iV_GetImageHeight(IntImages, IMAGE_ALLY_RESEARCH);
sAllyResearch.y = 10;
sAllyResearch.pDisplay = intDisplayAllyIcon;
displayForm = 0;
for (unsigned i = 0; i < apsObjectList.size(); ++i)
{
@ -3429,7 +3436,8 @@ static bool intAddObjectWindow(BASE_OBJECT *psObjects, BASE_OBJECT *psSelected,
{
continue; // Don't add the button if the objects dead.
}
IsFactory = false;
bool IsFactory = false;
bool isResearch = false;
/* Got an object - set the text and tip for the button */
switch (psObj->type)
@ -3478,6 +3486,7 @@ static bool intAddObjectWindow(BASE_OBJECT *psObjects, BASE_OBJECT *psSelected,
{
sBarInit2.size = WBAR_SCALE;
}
isResearch = true;
break;
default:
@ -3520,6 +3529,27 @@ static bool intAddObjectWindow(BASE_OBJECT *psObjects, BASE_OBJECT *psSelected,
}
sLabIntObjText.id++;
}
if (isResearch)
{
RESEARCH *Stat = ((RESEARCH_FACILITY *)((STRUCTURE *)psObj)->pFunctionality)->psSubject;
if (Stat != NULL)
{
// Show if allies are researching the same as us.
std::vector<AllyResearch> const &researches = listAllyResearch(Stat->ref);
unsigned numResearches = std::min<unsigned>(researches.size(), 4); // Only display at most 4 allies, since that's what there's room for.
for (unsigned ii = 0; ii < numResearches; ++ii)
{
sAllyResearch.formID = sBFormInit.id;
sAllyResearch.x = STAT_BUTWIDTH - (sAllyResearch.width + 2)*ii - sAllyResearch.width - 2;
sAllyResearch.UserData = PACKDWORD(Stat->ref - REF_RESEARCH_START, ii);
sAllyResearch.pTip = getPlayerName(researches[ii].player);
widgAddLabel(psWScreen, &sAllyResearch);
ASSERT(sAllyResearch.id <= IDOBJ_ALLYRESEARCHEND, " ");
++sAllyResearch.id;
}
}
}
// Add the power bar.
if (psObj->type != OBJ_DROID || (((DROID *)psObj)->droidType == DROID_CONSTRUCT || ((DROID *)psObj)->droidType == DROID_CYBORG_CONSTRUCT))
{
@ -4566,41 +4596,28 @@ static bool intAddStats(BASE_STATS **ppsStatsList, UDWORD numStats,
// if multiplayer, if research topic is being done by another ally then mark as such..
if (bMultiPlayer)
{
int labsDone = 0;
for (unsigned ii = 0; ii < MAX_PLAYERS && labsDone < 4; ++ii)
std::vector<AllyResearch> const &researches = listAllyResearch(Stat->ref);
unsigned numResearches = std::min<unsigned>(researches.size(), 4); // Only display at most 4 allies, since that's what there's room for.
for (unsigned ii = 0; ii < numResearches; ++ii)
{
if (ii != selectedPlayer && aiCheckAlliances(selectedPlayer, ii))
{
//check each research facility to see if they are doing this topic.
for (STRUCTURE *psOtherStruct = apsStructLists[ii]; psOtherStruct; psOtherStruct = psOtherStruct->psNext)
{
if (psOtherStruct->pStructureType->type == REF_RESEARCH
&& psOtherStruct->status == SS_BUILT
&& ((RESEARCH_FACILITY *)psOtherStruct->pFunctionality)->psSubject
&& ((RESEARCH_FACILITY *)psOtherStruct->pFunctionality)->psSubject->ref == Stat->ref
)
{
// add a label.
sLabInit = W_LABINIT();
sLabInit.formID = sBFormInit.id ;
sLabInit.id = IDSTAT_ALLYSTART + allyResearchIconCount;
sLabInit.width = iV_GetImageWidth(IntImages, IMAGE_ALLY_RESEARCH);
sLabInit.height = iV_GetImageHeight(IntImages, IMAGE_ALLY_RESEARCH);
sLabInit.x = STAT_BUTWIDTH - (sLabInit.width + 2) * labsDone - sLabInit.width - 2;
sLabInit.y = STAT_BUTHEIGHT - sLabInit.height - 3 - STAT_PROGBARHEIGHT;
sLabInit.UserData = ii;
sLabInit.pTip = getPlayerName(ii);
sLabInit.pDisplay = intDisplayAllyIcon;
widgAddLabel(psWScreen, &sLabInit);
// add a label.
sLabInit = W_LABINIT();
sLabInit.formID = sBFormInit.id ;
sLabInit.id = IDSTAT_ALLYSTART + allyResearchIconCount;
sLabInit.width = iV_GetImageWidth(IntImages, IMAGE_ALLY_RESEARCH);
sLabInit.height = iV_GetImageHeight(IntImages, IMAGE_ALLY_RESEARCH);
sLabInit.x = STAT_BUTWIDTH - (sLabInit.width + 2)*ii - sLabInit.width - 2;
sLabInit.y = STAT_BUTHEIGHT - sLabInit.height - 3 - STAT_PROGBARHEIGHT;
sLabInit.UserData = PACKDWORD(Stat->ref - REF_RESEARCH_START, ii);
sLabInit.pTip = getPlayerName(researches[ii].player);
sLabInit.pDisplay = intDisplayAllyIcon;
widgAddLabel(psWScreen, &sLabInit);
++labsDone;
++allyResearchIconCount;
ASSERT(allyResearchIconCount < IDSTAT_ALLYEND - IDSTAT_ALLYSTART, " ");
}
}
}
++allyResearchIconCount;
ASSERT(allyResearchIconCount < IDSTAT_ALLYEND - IDSTAT_ALLYSTART, " ");
}
if (labsDone > 0)
if (numResearches > 0)
{
W_BARINIT progress;
progress.formID = sBFormInit.id;

View File

@ -77,6 +77,8 @@
#define IDOBJ_CMDFACEND 3799 // The last ID for factory number labels
#define IDOBJ_CMDVTOLFACSTART 3800 // The first ID for VTOL factory number labels
#define IDOBJ_CMDVTOLFACEND 3849 // The last ID for VTOL factory number labels
#define IDOBJ_ALLYRESEARCHSTART 2637000 // The first ID for ally research labels
#define IDOBJ_ALLYRESEARCHEND 2637099 // The last ID for ally research labels
#define IDSTAT_FORM 14000 // The stats form for structure/droid/research type

View File

@ -3335,59 +3335,66 @@ void intDisplayAllyIcon(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DEC
UDWORD x = Label->x + xOffset;
UDWORD y = Label->y + yOffset;
iV_DrawImageTc(IntImages, IMAGE_ALLY_RESEARCH, IMAGE_ALLY_RESEARCH_TC, x, y, pal_GetTeamColour(getPlayerColour(psWidget->UserData)));
unsigned ref = UNPACKDWORD_HI(psWidget->UserData) + REF_RESEARCH_START;
unsigned num = UNPACKDWORD_LOW(psWidget->UserData);
std::vector<AllyResearch> const &researches = listAllyResearch(ref);
if (num >= researches.size())
{
return; // No icon to display. (Shouldn't really get here...)
}
if (!researches[num].active && realTime % 500 >= 250)
{
return; // If inactive, blink the icon. (Alternatively, we could use a different icon instead.)
}
iV_DrawImageTc(IntImages, IMAGE_ALLY_RESEARCH, IMAGE_ALLY_RESEARCH_TC, x, y, pal_GetTeamColour(getPlayerColour(researches[num].player)));
}
void intDisplayAllyBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours)
{
W_BARGRAPH *psBar = (W_BARGRAPH *)psWidget;
RESEARCH const &research = asResearch[psWidget->UserData];
std::vector<AllyResearch> const &researches = listAllyResearch(research.ref);
unsigned bestCompletion = 0;
const int researchNotStarted = 3600000;
int bestPowerNeeded = researchNotStarted;
int bestTimeToResearch = researchNotStarted;
int researchPowerCost = researchNotStarted;
for (int player = 0; player < MAX_PLAYERS; ++player)
for (std::vector<AllyResearch>::const_iterator i = researches.begin(); i != researches.end(); ++i)
{
if (player != selectedPlayer && aiCheckAlliances(selectedPlayer, player))
if (bestCompletion < i->completion)
{
// Check each research facility to see if they are doing this topic. (As opposed to having started the topic, but stopped researching it.)
for (STRUCTURE *psOtherStruct = apsStructLists[player]; psOtherStruct; psOtherStruct = psOtherStruct->psNext)
{
RESEARCH_FACILITY *res = (RESEARCH_FACILITY *)psOtherStruct->pFunctionality;
if (psOtherStruct->pStructureType->type == REF_RESEARCH && psOtherStruct->status == SS_BUILT &&
res->psSubject && res->psSubject->ref == asResearch[psWidget->UserData].ref)
{
unsigned completion = asPlayerResList[player][psWidget->UserData].currentPoints;
if (bestCompletion < completion)
{
bestCompletion = completion;
bestPowerNeeded = 0;
psBar->majorCol = pal_GetTeamColour(getPlayerColour(player));
}
int powerNeeded = checkPowerRequest(psOtherStruct);
if (powerNeeded == -1)
{
int rindex = res->psSubject->index;
int timeToResearch = (res->psSubject->researchPoints - asPlayerResList[player][rindex].currentPoints) / std::max(res->researchPoints, 1u);
bestTimeToResearch = std::min(bestTimeToResearch, timeToResearch);
}
else
{
bestPowerNeeded = std::min(bestPowerNeeded, powerNeeded);
researchPowerCost = res->psSubject->researchPower;
}
break;
}
}
bestCompletion = i->completion;
psBar->majorCol = pal_GetTeamColour(getPlayerColour(i->player));
}
if (!i->active)
{
continue; // Don't show remaining time/power, if the facility is currently being upgraded.
}
if (i->powerNeeded == -1)
{
bestTimeToResearch = std::min<unsigned>(bestTimeToResearch, i->timeToResearch);
}
else
{
bestPowerNeeded = std::min<unsigned>(bestPowerNeeded, i->powerNeeded);
researchPowerCost = research.researchPower;
}
}
setBarGraphValue(psBar, psBar->majorCol, bestCompletion, research.researchPoints);
if (bestTimeToResearch != researchNotStarted)
{
// Show research progress.
formatTimeText(psBar, bestTimeToResearch);
setBarGraphValue(psBar, psBar->majorCol, bestCompletion, asResearch[psWidget->UserData].researchPoints);
}
else if (bestCompletion > 0)
{
// Waiting for module...
psBar->text = QString::fromUtf8("—*—");
}
else if (bestPowerNeeded != researchNotStarted)
{

View File

@ -183,9 +183,8 @@ static KEY_CODE scanKeyBoardForBinding(void)
// ////////////////////////////////////////////////////////////////////////////
bool runKeyMapEditor(void)
{
UDWORD id;
id = widgRunScreen(psWScreen); // Run the current set of widgets
WidgetTriggers const &triggers = widgRunScreen(psWScreen);
unsigned id = triggers.empty()? 0 : triggers.front().widget->id; // Just use first click here, since the next click could be on another menu.
if(id == KM_RETURN) // return
{

View File

@ -417,13 +417,13 @@ void deleteSaveGame(char* saveGameName)
// otherwise cancel was selected..
bool runLoadSave(bool bResetMissionWidgets)
{
UDWORD id=0;
static char sDelete[PATH_MAX];
UDWORD i, campaign;
W_CONTEXT context;
char NewSaveGamePath[PATH_MAX] = {'\0'};
id = widgRunScreen(psRequestScreen);
WidgetTriggers const &triggers = widgRunScreen(psRequestScreen);
unsigned id = triggers.empty()? 0 : triggers.front().widget->id; // Just use first click here, since the next click could be on another menu.
sstrcpy(sRequestResult, ""); // set returned filename to null;

View File

@ -227,7 +227,9 @@ static GAMECODE renderLoop()
if(InGameOpUp || isInGamePopupUp) // ingame options menu up, run it!
{
unsigned widgval = widgRunScreen(psWScreen);
WidgetTriggers const &triggers = widgRunScreen(psWScreen);
unsigned widgval = triggers.empty()? 0 : triggers.front().widget->id; // Just use first click here, since the next click could be on another menu.
intProcessInGameOptions(widgval);
if(widgval == INTINGAMEOP_QUIT_CONFIRM || widgval == INTINGAMEOP_POPUP_QUIT)
{

View File

@ -786,17 +786,11 @@ bool startConnectionScreen(void)
void runConnectionScreen(void)
{
UDWORD id;
static char addr[128];
if(SettingsUp == true)
{
id = widgRunScreen(psConScreen); // Run the current set of widgets
}
else
{
id = widgRunScreen(psWScreen); // Run the current set of widgets
}
W_SCREEN *curScreen = SettingsUp? psConScreen : psWScreen;
WidgetTriggers const &triggers = widgRunScreen(curScreen);
unsigned id = triggers.empty()? 0 : triggers.front().widget->id; // Just use first click here, since the next click could be on another menu.
switch(id)
{
@ -892,15 +886,20 @@ bool joinGame(const char* host, uint32_t port)
setLobbyError(ERROR_NOERROR);
break;
case ERROR_WRONGPASSWORD:
{
// Change to GAMEFIND, screen with a password dialog.
changeTitleMode(GAMEFIND);
showPasswordForm();
if (widgRunScreen(psWScreen) != CON_PASSWORD) // Run the current set of widgets
WidgetTriggers const &triggers = widgRunScreen(psWScreen);
unsigned id = triggers.empty()? 0 : triggers.front().widget->id; // Just use first click here, since the next click could be on another menu.
if (id != CON_PASSWORD) // Run the current set of widgets
{
return false;
}
NETsetGamePassword(widgGetString(psWScreen, CON_PASSWORD));
break;
}
default:
break;
}
@ -1099,7 +1098,6 @@ static void removeGames(void)
void runGameFind(void )
{
UDWORD id;
static UDWORD lastupdate=0;
static char game_password[StringSize];
@ -1118,7 +1116,8 @@ void runGameFind(void )
addConsoleBox();
}
id = widgRunScreen(psWScreen); // Run the current set of widgets
WidgetTriggers const &triggers = widgRunScreen(psWScreen);
unsigned id = triggers.empty()? 0 : triggers.front().widget->id; // Just use first click here, since the next click could be on another menu.
if(id == CON_CANCEL) // ok
{
@ -3686,7 +3685,6 @@ void frontendMultiMessages(void)
void runMultiOptions(void)
{
static UDWORD lastrefresh = 0;
UDWORD id, i;
char sTemp[128], oldGameMap[128];
int oldMaxPlayers;
PLAYERSTATS playerStats;
@ -3698,7 +3696,7 @@ void runMultiOptions(void)
frontendMultiMessages();
if (NetPlay.isHost)
{
for (i = 0; i < MAX_PLAYERS; i++)
for (unsigned i = 0; i < MAX_PLAYERS; i++)
{
// send it for each player that needs it
if (NetPlay.players[i].wzFile.isSending)
@ -3761,7 +3759,9 @@ void runMultiOptions(void)
if(multiRequestUp)
{
id = widgRunScreen(psRScreen); // a requester box is up.
WidgetTriggers const &triggers = widgRunScreen(psRScreen);
unsigned id = triggers.empty()? 0 : triggers.front().widget->id; // Just use first click here, since the next click could be on another menu.
LEVEL_DATASET *mapData;
bool isHoverPreview;
if (runMultiRequester(id, &id, (char *)&sTemp, &mapData, &isHoverPreview))
@ -3833,7 +3833,9 @@ void runMultiOptions(void)
hideTime = 0;
}
id = widgRunScreen(psWScreen); // run the widgets.
WidgetTriggers const &triggers = widgRunScreen(psWScreen);
unsigned id = triggers.empty()? 0 : triggers.front().widget->id; // Just use first click here, since the next click could be on another menu.
processMultiopWidgets(id);
}

View File

@ -274,16 +274,15 @@ bool startLimitScreen(void)
void runLimitScreen(void)
{
UDWORD i, id, statid;
frontendMultiMessages(); // network stuff.
id = widgRunScreen(psWScreen); // Run the current set of widgets
WidgetTriggers const &triggers = widgRunScreen(psWScreen);
unsigned id = triggers.empty()? 0 : triggers.front().widget->id; // Just use first click here, since the next click could be on another menu.
// sliders
if((id > IDLIMITS_ENTRIES_START) && (id< IDLIMITS_ENTRIES_END))
{
statid = widgGetFromID(psWScreen,id-1)->UserData ;
unsigned statid = widgGetFromID(psWScreen,id-1)->UserData;
if(statid)
{
asStructLimits[0][statid].limit = (UBYTE) ((W_SLIDER*)(widgGetFromID(psWScreen,id)))->pos;
@ -296,7 +295,7 @@ void runLimitScreen(void)
{
case IDLIMITS_RETURN:
// reset the sliders..
for (i = 0; i < numStructureStats ; ++i)
for (unsigned i = 0; i < numStructureStats; ++i)
{
asStructLimits[0][i].limit = asStructLimits[0][i].globalLimit;
}

View File

@ -24,6 +24,7 @@
*
*/
#include <string.h>
#include <map>
#include "lib/framework/frame.h"
#include "lib/framework/strres.h"
@ -47,6 +48,7 @@
#include "template.h"
#include "qtscript.h"
//used to calc the research power
#define RESEARCH_FACTOR 32
#define RESEARCH_MAX_POWER 450
@ -2035,3 +2037,70 @@ static void switchComponent(DROID *psDroid, UDWORD oldType, UDWORD oldCompInc,
return;
}
}
static inline bool allyResearchSortFunction(AllyResearch const &a, AllyResearch const &b)
{
if (a.active != b.active) { return a.active; }
if (a.timeToResearch != b.timeToResearch) { return (unsigned)a.timeToResearch < (unsigned)b.timeToResearch; } // Unsigned cast = sort -1 as infinite.
if (a.powerNeeded != b.powerNeeded) { return (unsigned)a.powerNeeded < (unsigned)b.powerNeeded; }
if (a.completion != b.completion) { return a.completion > b.completion; }
return a.player < b.player;
}
std::vector<AllyResearch> const &listAllyResearch(unsigned ref)
{
static uint32_t lastGameTime = ~0;
static std::map<unsigned, std::vector<AllyResearch> > researches;
static const std::vector<AllyResearch> noAllyResearch;
if (gameTime != lastGameTime)
{
lastGameTime = gameTime;
researches.clear();
for (int player = 0; player < MAX_PLAYERS; ++player)
{
if (player == selectedPlayer || !aiCheckAlliances(selectedPlayer, player))
{
continue; // Skip this player, not an ally.
}
// Check each research facility to see if they are doing this topic. (As opposed to having started the topic, but stopped researching it.)
for (STRUCTURE *psStruct = apsStructLists[player]; psStruct != NULL; psStruct = psStruct->psNext)
{
RESEARCH_FACILITY *res = (RESEARCH_FACILITY *)psStruct->pFunctionality;
if (psStruct->pStructureType->type != REF_RESEARCH || res->psSubject == NULL)
{
continue; // Not a researching research facility.
}
RESEARCH const &subject = *res->psSubject;
PLAYER_RESEARCH const &playerRes = asPlayerResList[player][subject.index];
unsigned cRef = subject.ref;
AllyResearch r;
r.player = player;
r.completion = playerRes.currentPoints;
r.powerNeeded = checkPowerRequest(psStruct);
r.timeToResearch = -1;
if (r.powerNeeded == -1)
{
r.timeToResearch = (subject.researchPoints - playerRes.currentPoints) / std::max(res->researchPoints, 1u);
}
r.active = psStruct->status == SS_BUILT;
researches[cRef].push_back(r);
}
}
for (std::map<unsigned, std::vector<AllyResearch> >::iterator i = researches.begin(); i != researches.end(); ++i)
{
std::sort(i->second.begin(), i->second.end(), allyResearchSortFunction);
}
}
std::map<unsigned, std::vector<AllyResearch> >::const_iterator i = researches.find(ref);
if (i == researches.end())
{
return noAllyResearch;
}
return i->second;
}

View File

@ -151,4 +151,14 @@ extern bool researchInitVars(void);
bool researchAvailable(int inc, int playerID, QUEUE_MODE mode);
struct AllyResearch
{
unsigned player;
int completion;
int powerNeeded;
int timeToResearch;
bool active;
};
std::vector<AllyResearch> const &listAllyResearch(unsigned ref);
#endif // __INCLUDED_SRC_RESEARCH_H__