--- a/hedgewars/hwLibrary.pas Sat Nov 01 22:51:07 2014 +0300
+++ b/hedgewars/hwLibrary.pas Mon Nov 03 00:01:02 2014 +0300
@@ -160,6 +160,7 @@
getTeamsList,
tryAddTeam,
tryRemoveTeam,
+ changeTeamColor,
// dunno what these are
RunEngine,
LoadLocaleWrapper,
--- a/hedgewars/uFLGameConfig.pas Sat Nov 01 22:51:07 2014 +0300
+++ b/hedgewars/uFLGameConfig.pas Mon Nov 03 00:01:02 2014 +0300
@@ -12,8 +12,9 @@
procedure setSeed(seed: PChar); cdecl;
function getSeed: PChar; cdecl;
-procedure tryAddTeam(teamName: PChar);
-procedure tryRemoveTeam(teamName: PChar);
+procedure tryAddTeam(teamName: PChar); cdecl;
+procedure tryRemoveTeam(teamName: PChar); cdecl;
+procedure changeTeamColor(teamName: PChar; dir: LongInt); cdecl;
implementation
uses uFLIPC, hwengine, uFLUtils, uFLTeams, uFLData;
@@ -203,7 +204,7 @@
end;
-procedure tryAddTeam(teamName: PChar);
+procedure tryAddTeam(teamName: PChar); cdecl;
var msg: ansistring;
i, hn, hedgehogsNumber: Longword;
team: PTeam;
@@ -235,20 +236,20 @@
teams[i].hogsNumber:= hn;
teams[i].color:= c;
- end;
-
- msg:= '0' + #10 + teamName;
+ msg:= '0' + #10 + teamName;
+ guiCallbackFunction(guiCallbackPointer, mtAddPlayingTeam, @msg[1], length(msg));
- guiCallbackFunction(guiCallbackPointer, mtAddPlayingTeam, @msg[1], length(msg));
+ msg:= teamName + #10 + colorsSet[teams[i].color];
+ guiCallbackFunction(guiCallbackPointer, mtTeamColor, @msg[1], length(msg));
- msg:= teamName;
-
- guiCallbackFunction(guiCallbackPointer, mtRemoveTeam, @msg[1], length(msg))
+ msg:= teamName;
+ guiCallbackFunction(guiCallbackPointer, mtRemoveTeam, @msg[1], length(msg))
+ end
end;
-procedure tryRemoveTeam(teamName: PChar);
+procedure tryRemoveTeam(teamName: PChar); cdecl;
var msg: ansistring;
i: Longword;
tn: shortstring;
@@ -278,4 +279,27 @@
guiCallbackFunction(guiCallbackPointer, mtAddTeam, @msg[1], length(msg))
end;
+
+procedure changeTeamColor(teamName: PChar; dir: LongInt); cdecl;
+var i, dc: Longword;
+ tn: shortstring;
+ msg: ansistring;
+begin
+ with currentConfig do
+ begin
+ i:= 0;
+ tn:= teamName;
+ while (i < 8) and (teams[i].teamName <> tn) do
+ inc(i);
+ // team not found???
+ if (i > 7) then exit;
+
+ if dir >= 0 then dc:= 1 else dc:= 8;
+ teams[i].color:= (teams[i].color + dc) mod 9;
+
+ msg:= tn + #10 + colorsSet[teams[i].color];
+ guiCallbackFunction(guiCallbackPointer, mtTeamColor, @msg[1], length(msg))
+ end
+end;
+
end.
--- a/hedgewars/uFLTypes.pas Sat Nov 01 22:51:07 2014 +0300
+++ b/hedgewars/uFLTypes.pas Mon Nov 03 00:01:02 2014 +0300
@@ -2,7 +2,8 @@
interface
type
- TMessageType = (mtPreview, mtAddPlayingTeam, mtRemovePlayingTeam, mtAddTeam, mtRemoveTeam);
+ TMessageType = (mtPreview, mtAddPlayingTeam, mtRemovePlayingTeam, mtAddTeam, mtRemoveTeam
+ , mtTeamColor);
TIPCMessage = record
str: shortstring;
--- a/qmlFrontend/flib.h Sat Nov 01 22:51:07 2014 +0300
+++ b/qmlFrontend/flib.h Mon Nov 03 00:01:02 2014 +0300
@@ -13,6 +13,7 @@
, MSG_REMOVEPLAYINGTEAM
, MSG_ADDTEAM
, MSG_REMOVETEAM
+ , MSG_TEAMCOLOR
};
typedef union string255_
@@ -42,8 +43,9 @@
typedef uint32_t getThemeIcon_t(char * theme, char * buffer, uint32_t size);
typedef char **getTeamsList_t();
-typedef void tryAddTeam_t(const char * seed);
-typedef void tryRemoveTeam_t(const char * seed);
+typedef void tryAddTeam_t(const char * teamName);
+typedef void tryRemoveTeam_t(const char * teamName);
+typedef void changeTeamColor_t(const char * teamName, int32_t dir);
#ifdef __cplusplus
}
--- a/qmlFrontend/hwengine.cpp Sat Nov 01 22:51:07 2014 +0300
+++ b/qmlFrontend/hwengine.cpp Mon Nov 03 00:01:02 2014 +0300
@@ -25,6 +25,7 @@
getTeamsList_t *flibGetTeamsList;
tryAddTeam_t * flibTryAddTeam;
tryRemoveTeam_t * flibTryRemoveTeam;
+ changeTeamColor_t * flibChangeTeamColor;
}
Q_DECLARE_METATYPE(MessageType);
@@ -58,6 +59,7 @@
flibGetTeamsList = (getTeamsList_t*) hwlib.resolve("getTeamsList");
flibTryAddTeam = (tryAddTeam_t*) hwlib.resolve("tryAddTeam");
flibTryRemoveTeam = (tryRemoveTeam_t*) hwlib.resolve("tryRemoveTeam");
+ flibChangeTeamColor = (changeTeamColor_t*) hwlib.resolve("changeTeamColor");
flibInit("/usr/home/unC0Rr/Sources/Hedgewars/Hedgewars-GC/share/hedgewars/Data", "/usr/home/unC0Rr/.hedgewars");
flibRegisterGUIMessagesCallback(this, &guiMessagesCallback);
@@ -143,6 +145,11 @@
emit localTeamRemoved(msg);
break;
}
+ case MSG_TEAMCOLOR: {
+ QStringList l = QString::fromUtf8(msg).split('\n');
+ emit teamColorChanged(l[0], QColor::fromRgba(l[1].toInt()).name());
+ break;
+ }
}
}
@@ -190,3 +197,8 @@
{
flibResetGameConfig();
}
+
+void HWEngine::changeTeamColor(const QString &teamName, int dir)
+{
+ flibChangeTeamColor(teamName.toUtf8().constData(), dir);
+}
--- a/qmlFrontend/hwengine.h Sat Nov 01 22:51:07 2014 +0300
+++ b/qmlFrontend/hwengine.h Mon Nov 03 00:01:02 2014 +0300
@@ -27,6 +27,7 @@
Q_INVOKABLE void tryAddTeam(const QString & teamName);
Q_INVOKABLE void tryRemoveTeam(const QString & teamName);
+ Q_INVOKABLE void changeTeamColor(const QString & teamName, int dir);
signals:
void previewImageChanged();
@@ -36,6 +37,8 @@
void playingTeamAdded(const QString & teamName, int aiLevel, bool isLocal);
void playingTeamRemoved(const QString & teamName);
+ void teamColorChanged(const QString & teamName, const QString & colorValue);
+
public slots:
private:
--- a/qmlFrontend/qml/qmlFrontend/GameConfig.qml Sat Nov 01 22:51:07 2014 +0300
+++ b/qmlFrontend/qml/qmlFrontend/GameConfig.qml Mon Nov 03 00:01:02 2014 +0300
@@ -105,25 +105,52 @@
border.color: "#eaea00"
Row {
- Text { text: name }
+ Rectangle {
+ height: 20
+ width: height
+ color: teamColor
+ border.width: 2
+ border.color: "#eaea00"
+
+ MouseArea {
+ z: 1
+ anchors.fill: parent
+ onClicked: HWEngine.changeTeamColor(name, 1)
+ }
+ }
+
+ Text { text: name
+ MouseArea {
+ z: 1
+ anchors.fill: parent
+ onClicked: HWEngine.tryRemoveTeam(name)
+ }
+ }
}
- MouseArea {
- z: 1
- anchors.fill: parent
- onClicked: HWEngine.tryRemoveTeam(name)
- }
+
}
Connections {
target: HWEngine
- onPlayingTeamAdded: playingTeamsModel.append({"aiLevel": aiLevel, "name": teamName, "local": isLocal})
+ onPlayingTeamAdded: playingTeamsModel.append({
+ "aiLevel": aiLevel
+ , "name": teamName
+ , "local": isLocal
+ , "teamColor": "#000000"
+ })
onPlayingTeamRemoved: {
var i = playingTeamsModel.count - 1;
while ((i >= 0) && (playingTeamsModel.get(i).name !== teamName)) --i
if(i >= 0) playingTeamsModel.remove(i, 1)
}
+ onTeamColorChanged: {
+ var i = playingTeamsModel.count - 1;
+ while ((i >= 0) && (playingTeamsModel.get(i).name !== teamName)) --i
+
+ if(i >= 0) playingTeamsModel.setProperty(i, "teamColor", colorValue)
+ }
}
}