Skip to content

Commit e5d6893

Browse files
authored
minor bug fixes in v0.8.5 (#361)
1 parent 4d58449 commit e5d6893

File tree

4 files changed

+23
-21
lines changed

4 files changed

+23
-21
lines changed

source/creator/actions/node.d

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public:
3030
Which index in to the parent the nodes should be placed
3131
*/
3232
size_t parentOffset;
33+
float[uint] zSort;
3334

3435
/**
3536
Previous parent of node
@@ -76,6 +77,7 @@ public:
7677
originalTransform[sn.uuid] = sn.localTransform;
7778
prevParents[sn.uuid] = sn.parent;
7879
prevOffsets[sn.uuid] = sn.getIndexInParent();
80+
zSort[sn.uuid] = sn.zSort;
7981
}
8082

8183
// Set relative position
@@ -100,6 +102,9 @@ public:
100102
if (sn.uuid in prevParents && prevParents[sn.uuid]) {
101103
if (!sn.lockToRoot()) sn.setRelativeTo(prevParents[sn.uuid]);
102104
sn.reparent(prevParents[sn.uuid], prevOffsets[sn.uuid]);
105+
if (sn.uuid in zSort) {
106+
sn.zSort = zSort[sn.uuid] - prevParents[sn.uuid].zSort();
107+
}
103108
sn.localTransform = originalTransform[sn.uuid];
104109
sn.transformChanged();
105110
} else sn.parent = null;

source/creator/io/package.d

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public import creator.io.imageexport;
1414
import tinyfiledialogs;
1515
public import tinyfiledialogs : TFD_Filter;
1616
import std.string;
17+
import std.uri;
1718
import i18n;
1819

1920
import bindbc.sdl;
@@ -80,7 +81,7 @@ string incShowImportDialog(const(TFD_Filter)[] filters, string title, bool multi
8081
op.multiple = multiple;
8182
auto promise = dpFileChooserOpenFile(getWindowHandle(), title, op);
8283
promise.await();
83-
return promise.uriFromPromise();
84+
return promise.uriFromPromise().decode;
8485
} catch (Throwable ex) {
8586

8687
// FALLBACK: If xdg-desktop-portal is not available then try tinyfiledialogs.
@@ -108,7 +109,7 @@ string incShowOpenFolderDialog(string title = "Open...") {
108109
op.directory = true;
109110
auto promise = dpFileChooserOpenFile(getWindowHandle(), title, op);
110111
promise.await();
111-
return promise.uriFromPromise();
112+
return promise.uriFromPromise().decode;
112113
} catch (Throwable _) {
113114

114115
// FALLBACK: If xdg-desktop-portal is not available then try tinyfiledialogs.
@@ -132,7 +133,7 @@ string incShowOpenDialog(const(TFD_Filter)[] filters, string title = "Open...")
132133
op.filters = tfdToFileFilter(filters);
133134
auto promise = dpFileChooserOpenFile(getWindowHandle(), title, op);
134135
promise.await();
135-
return promise.uriFromPromise();
136+
return promise.uriFromPromise().decode;
136137
} catch (Throwable ex) {
137138

138139
// FALLBACK: If xdg-desktop-portal is not available then try tinyfiledialogs.
@@ -160,7 +161,7 @@ string incShowSaveDialog(const(TFD_Filter)[] filters, string fname, string title
160161
op.filters = tfdToFileFilter(filters);
161162
auto promise = dpFileChooserSaveFile(getWindowHandle(), title, op);
162163
promise.await();
163-
return promise.uriFromPromise();
164+
return promise.uriFromPromise().decode;
164165
} catch (Throwable ex) {
165166

166167
// FALLBACK: If xdg-desktop-portal is not available then try tinyfiledialogs.

source/creator/panels/inspector.d

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import std.string;
2121
import std.algorithm.searching;
2222
import std.algorithm.mutation;
2323
import std.conv;
24+
import std.utf;
2425
import i18n;
2526

2627
// Drag drop data
@@ -281,7 +282,11 @@ void incModelModeHeader(Node node) {
281282
igPushID(node.uuid);
282283
string typeString = "%s".format(incTypeIdToIcon(node.typeId()));
283284
auto len = incMeasureString(typeString);
284-
incInputText("###MODEL_NODE_HEADER", incAvailableSpace().x-24, node.name);
285+
if (incInputText("###MODEL_NODE_HEADER", incAvailableSpace().x-24, node.name)) {
286+
try {
287+
node.name = node.name.toStringz.fromStringz;
288+
} catch (std.utf.UTFException e) {}
289+
}
285290
igSameLine(0, 0);
286291
incDummy(ImVec2(-len.x, len.y));
287292
igSameLine(0, 0);

source/creator/windows/flipconfig.d

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ FlipPair[] incGetFlipPairs() {
132132

133133
FlipPair incGetFlipPairFor(Node node) {
134134
foreach (pair; flipPairs) {
135-
if (pair.parts[1] !is null && (pair.parts[0].uuid == node.uuid || pair.parts[1].uuid == node.uuid)) {
135+
if (pair.parts[0] !is null &&
136+
pair.parts[1] !is null &&
137+
(pair.parts[0].uuid == node.uuid || pair.parts[1].uuid == node.uuid)) {
136138
return pair;
137139
}
138140
}
@@ -159,24 +161,13 @@ private:
159161

160162

161163
void autoPair(string part1, string part2) {
162-
// FIXME: this code sometimes doesn't work well with multi-byte utf-8 charset.
163-
string truncate(string str) {
164-
int i;
165-
for (i = (cast(int)str.length) - 1; i >= 0; i --) {
166-
if (str[i] != '\0')
167-
break;
168-
}
169-
if (i >= 0) {
170-
return str[0..i];
171-
}
172-
return "";
173-
}
174-
175164
foreach(i, ref Node node; nodes) {
176-
string targetName = node.name.replace(part1, part2);
165+
string node1Name = node.name.toStringz.fromStringz;
166+
string targetName = node1Name.replace(part1, part2);
177167
if (node.uuid in map) continue;
178168
foreach (ref Node node2; nodes) {
179-
if (node.name.indexOf(part1) >= 0 && truncate(node2.name) == truncate(targetName)) {
169+
string node2Name = node2.name.toStringz.fromStringz;
170+
if (node1Name.indexOf(part1) >= 0 && node2Name == targetName) {
180171
if (node2.uuid != node.uuid) {
181172
pairs ~= new FlipPair([node, node2], "");
182173
map[node.uuid] = pairs.length - 1;

0 commit comments

Comments
 (0)