|
@@ -7,6 +7,7 @@ Rectangle {
|
|
|
property var mapPath: ""
|
|
property var mapPath: ""
|
|
|
property var playerConfigs: []
|
|
property var playerConfigs: []
|
|
|
property bool loading: false
|
|
property bool loading: false
|
|
|
|
|
+ property string previewId: ""
|
|
|
|
|
|
|
|
radius: Theme.radiusLarge
|
|
radius: Theme.radiusLarge
|
|
|
color: Theme.cardBase
|
|
color: Theme.cardBase
|
|
@@ -17,6 +18,7 @@ Rectangle {
|
|
|
function refreshPreview() {
|
|
function refreshPreview() {
|
|
|
if (!mapPath || mapPath === "" || !playerConfigs || playerConfigs.length === 0) {
|
|
if (!mapPath || mapPath === "" || !playerConfigs || playerConfigs.length === 0) {
|
|
|
previewImage.source = "";
|
|
previewImage.source = "";
|
|
|
|
|
+ previewId = "";
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -26,8 +28,19 @@ Rectangle {
|
|
|
|
|
|
|
|
loading = true;
|
|
loading = true;
|
|
|
try {
|
|
try {
|
|
|
|
|
+ // Generate a unique ID based on map path and player configs
|
|
|
|
|
+ var configStr = JSON.stringify(playerConfigs);
|
|
|
|
|
+ var newId = mapPath + "_" + configStr.length + "_" + Date.now();
|
|
|
|
|
+
|
|
|
var preview = game.generate_map_preview(mapPath, playerConfigs);
|
|
var preview = game.generate_map_preview(mapPath, playerConfigs);
|
|
|
- previewImage.image = preview;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (typeof mapPreviewProvider !== "undefined") {
|
|
|
|
|
+ mapPreviewProvider.set_preview_image(newId, preview);
|
|
|
|
|
+ previewId = newId;
|
|
|
|
|
+ // Force image reload by changing the source
|
|
|
|
|
+ previewImage.source = "image://mappreview/" + newId;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
loading = false;
|
|
loading = false;
|
|
|
} catch (e) {
|
|
} catch (e) {
|
|
|
console.error("MapPreview: Failed to generate preview:", e);
|
|
console.error("MapPreview: Failed to generate preview:", e);
|
|
@@ -76,7 +89,8 @@ Rectangle {
|
|
|
height: width
|
|
height: width
|
|
|
fillMode: Image.PreserveAspectFit
|
|
fillMode: Image.PreserveAspectFit
|
|
|
smooth: true
|
|
smooth: true
|
|
|
- visible: !loading && source !== ""
|
|
|
|
|
|
|
+ cache: false
|
|
|
|
|
+ visible: !loading && status === Image.Ready
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
Text {
|
|
Text {
|
|
@@ -85,7 +99,7 @@ Rectangle {
|
|
|
color: Theme.textHint
|
|
color: Theme.textHint
|
|
|
font.pixelSize: 13
|
|
font.pixelSize: 13
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
- visible: !loading && previewImage.source === "" && mapPath === ""
|
|
|
|
|
|
|
+ visible: !loading && previewImage.status !== Image.Ready && mapPath === ""
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
Text {
|
|
Text {
|
|
@@ -94,7 +108,7 @@ Rectangle {
|
|
|
color: Theme.textHint
|
|
color: Theme.textHint
|
|
|
font.pixelSize: 13
|
|
font.pixelSize: 13
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
- visible: !loading && previewImage.source === "" && mapPath !== ""
|
|
|
|
|
|
|
+ visible: !loading && previewImage.status !== Image.Ready && mapPath !== ""
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
Item {
|