Skip to content

Commit 367dcbe

Browse files
author
ozelot379
committed
Convert dialog ui
1 parent 092a45c commit 367dcbe

5 files changed

Lines changed: 126 additions & 102 deletions

File tree

‎src/converter/BarConverter.js‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@ class BarConverter extends AbstractConverter {
88
* @inheritDoc
99
*/
1010
async convert() {
11-
const [icons, bars, nubs] = this.data;
11+
const [from, factor_detect, bars, nubs] = this.data;
1212

13-
if (!await this.output.exists(icons)) {
13+
if (!await this.output.exists(from)) {
1414
return [];
1515
}
1616

17-
const icons_image = await this.readImage(icons);
17+
const image_from = await this.readImage(from);
1818

19-
const factor = (icons_image.getWidth() / 256);
19+
const factor = (image_from.getWidth() / factor_detect);
2020

2121
for (const [y, tos] of bars) {
22-
const image = icons_image.clone().crop(0, (y * factor), (182 * factor), (5 * factor));
22+
const image = image_from.clone().crop(0, (y * factor), (182 * factor), (5 * factor));
2323

2424
const metadata = {
25-
nineslice_size: [factor, 0, factor, 0],
26-
base_size: [image.getWidth(), image.getHeight()]
25+
nineslice_size: [1, 0, 1, 0],
26+
base_size: [182, 5]
2727
};
2828

2929
for (const [to, colorize] of tos) {
@@ -52,6 +52,7 @@ class BarConverter extends AbstractConverter {
5252
return [
5353
[
5454
"textures/gui/icons.png",
55+
256,
5556
[
5657
[64, [
5758
["textures/gui/achievements/hotdogempty"],

‎src/converter/ButtonConverter.js‎

Lines changed: 78 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,26 @@ class ButtonConverter extends AbstractConverter {
88
* @inheritDoc
99
*/
1010
async convert() {
11-
const [from, buttons, borders] = this.data;
11+
const [from, factor_detect, buttons, borders] = this.data;
1212

1313
if (!await this.output.exists(from)) {
1414
return [];
1515
}
1616

1717
const image_from = await this.readImage(from);
1818

19-
const factor = (image_from.getWidth() / 256);
19+
image_from.ensureMinWidth(factor_detect);
20+
21+
const factor = (image_from.getWidth() / factor_detect);
2022

2123
for (const [x, y, width, height, tos] of buttons) {
2224
const image = image_from.clone().crop((x * factor), (y * factor), (width * factor), (height * factor));
2325

2426
image.autoCropTransparent();
2527

2628
const metadata = {
27-
nineslice_size: factor,
28-
base_size: [image.getWidth(), image.getHeight()]
29+
nineslice_size: 4,
30+
base_size: [width, height]
2931
};
3032

3133
for (const to of tos) {
@@ -39,8 +41,8 @@ class ButtonConverter extends AbstractConverter {
3941

4042
const transparent_image = await this.createImage(factor, factor);
4143
const transparent_image_metadata = {
42-
nineslice_size: factor,
43-
base_size: [transparent_image.getWidth(), transparent_image.getHeight()]
44+
nineslice_size: 0,
45+
base_size: [1, 1]
4446
};
4547
for (const to of borders) {
4648
const to_png = to + ".png";
@@ -58,66 +60,76 @@ class ButtonConverter extends AbstractConverter {
5860
*/
5961
static get DEFAULT_CONVERTER_DATA() {
6062
return [
61-
["textures/gui/widgets.png", [
62-
[0, 46, 200, 20, [
63-
"textures/ui/button_borderless_darkpressednohover",
64-
"textures/ui/button_borderless_lightpressednohover",
65-
"textures/ui/disabledButtonNoBorder"
66-
]],
67-
[0, 66, 200, 20, [
68-
"textures/ui/button_borderless_dark",
69-
"textures/ui/button_borderless_light",
70-
"textures/ui/pocket_button_default"
71-
]],
72-
[0, 86, 200, 20, [
73-
"textures/ui/button_borderless_darkhover",
74-
"textures/ui/button_borderless_darkpressed",
75-
"textures/ui/button_borderless_lighthover",
76-
"textures/ui/button_borderless_lightpressed",
77-
"textures/ui/pocket_button_hover",
78-
"textures/ui/pocket_button_pressed"
79-
]]
80-
], [
81-
"textures/ui/focus_border_selected",
82-
"textures/ui/focus_border_white"
83-
]],
84-
["textures/gui/container/creative_inventory/tabs.png", [
85-
[0, 0, 28, 32, [
86-
"textures/ui/pocket_tab_left_side",
87-
"textures/ui/TabLeftBack",
88-
"textures/ui/TabLeftBackBottomMost",
89-
"textures/ui/TabLeftBackTopMost",
90-
"textures/ui/TabTopBackLeftMost"
91-
]],
92-
[28, 0, 28, 32, [
93-
"textures/ui/TabTopBack"
94-
]],
95-
[140, 0, 28, 32, [
96-
"textures/ui/pocket_tab_right_side",
97-
"textures/ui/TabRightBack",
98-
"textures/ui/TabRightBackBottomMost",
99-
"textures/ui/TabRightBackTopMost",
100-
"textures/ui/TabTopBackRightMost",
101-
"textures/ui/TabTopBackRightMostDark",
102-
"textures/ui/XTab"
103-
]],
104-
[0, 32, 28, 32, [
105-
"textures/ui/TabLeftFront",
106-
"textures/ui/TabLeftFrontBottomMost",
107-
"textures/ui/TabLeftFrontTopMost",
108-
"textures/ui/TabTopFrontLeftMost"
109-
]],
110-
[28, 32, 28, 32, [
111-
"textures/ui/TabTopFront"
112-
]],
113-
[140, 32, 28, 32, [
114-
"textures/ui/TabRightFront",
115-
"textures/ui/TabRightFrontBottomMost",
116-
"textures/ui/TabRightFrontTopMost",
117-
"textures/ui/TabTopFrontRightMost",
118-
"textures/ui/TabTopFrontRightMostDark"
119-
]]
120-
], []]
63+
[
64+
"textures/gui/widgets.png",
65+
256,
66+
[
67+
[0, 46, 200, 20, [
68+
"textures/ui/button_borderless_darkpressednohover",
69+
"textures/ui/button_borderless_lightpressednohover",
70+
"textures/ui/disabledButtonNoBorder"
71+
]],
72+
[0, 66, 200, 20, [
73+
"textures/ui/button_borderless_dark",
74+
"textures/ui/button_borderless_light",
75+
"textures/ui/pocket_button_default"
76+
]],
77+
[0, 86, 200, 20, [
78+
"textures/ui/button_borderless_darkhover",
79+
"textures/ui/button_borderless_darkpressed",
80+
"textures/ui/button_borderless_lighthover",
81+
"textures/ui/button_borderless_lightpressed",
82+
"textures/ui/pocket_button_hover",
83+
"textures/ui/pocket_button_pressed"
84+
]]
85+
],
86+
[
87+
"textures/ui/focus_border_selected",
88+
"textures/ui/focus_border_white"
89+
]
90+
],
91+
[
92+
"textures/gui/container/creative_inventory/tabs.png",
93+
256,
94+
[
95+
[0, 0, 28, 32, [
96+
"textures/ui/pocket_tab_left_side",
97+
"textures/ui/TabLeftBack",
98+
"textures/ui/TabLeftBackBottomMost",
99+
"textures/ui/TabLeftBackTopMost",
100+
"textures/ui/TabTopBackLeftMost"
101+
]],
102+
[28, 0, 28, 32, [
103+
"textures/ui/TabTopBack"
104+
]],
105+
[140, 0, 28, 32, [
106+
"textures/ui/pocket_tab_right_side",
107+
"textures/ui/TabRightBack",
108+
"textures/ui/TabRightBackBottomMost",
109+
"textures/ui/TabRightBackTopMost",
110+
"textures/ui/TabTopBackRightMost",
111+
"textures/ui/TabTopBackRightMostDark",
112+
"textures/ui/XTab"
113+
]],
114+
[0, 32, 28, 32, [
115+
"textures/ui/TabLeftFront",
116+
"textures/ui/TabLeftFrontBottomMost",
117+
"textures/ui/TabLeftFrontTopMost",
118+
"textures/ui/TabTopFrontLeftMost"
119+
]],
120+
[28, 32, 28, 32, [
121+
"textures/ui/TabTopFront"
122+
]],
123+
[140, 32, 28, 32, [
124+
"textures/ui/TabRightFront",
125+
"textures/ui/TabRightFrontBottomMost",
126+
"textures/ui/TabRightFrontTopMost",
127+
"textures/ui/TabTopFrontRightMost",
128+
"textures/ui/TabTopFrontRightMostDark"
129+
]]
130+
],
131+
[]
132+
]
121133
];
122134
}
123135
}

‎src/converter/DespriteConverter.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ class DespriteConverter extends AbstractConverter {
1616

1717
const image_from = await this.readImage(input);
1818

19+
image_from.ensureMinWidth(factor_detect);
20+
1921
const factor = (image_from.getWidth() / factor_detect);
2022

2123
for (const [x, y, width, height, to] of sprites) {

‎src/converter/DialogConverter.js‎

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,43 @@ class DialogConverter extends AbstractConverter {
88
* @inheritDoc
99
*/
1010
async convert() {
11-
const [from, dialogs] = this.data;
11+
const [from, factor_detect, dialogs] = this.data;
1212

1313
if (!await this.output.exists(from)) {
1414
return [];
1515
}
1616

1717
const image_from = await this.readImage(from);
1818

19-
const factor = (image_from.getWidth() / 256);
19+
image_from.ensureMinWidth(factor_detect);
20+
21+
const factor = (image_from.getWidth() / factor_detect);
2022

2123
for (const [x, y, width, height, _base_nineslice_size, tos] of dialogs) {
2224
const base_nineslice_size = _base_nineslice_size.map(size => size * factor);
2325

2426
const image = image_from.clone().crop((x * factor), (y * factor), (width * factor), (height * factor));
2527

26-
for (const [to, to_nineslice_size] of tos) {
27-
const to_image = await this.createImage((to_nineslice_size[0] + to_nineslice_size[2] + (3 * factor)), (to_nineslice_size[1] + to_nineslice_size[3] + (3 * factor)));
28+
for (const [to, _to_nineslice_size] of tos) {
29+
const to_nineslice_size = _to_nineslice_size.map(size => size * factor);
30+
31+
const to_image = await this.createImage((to_nineslice_size[0] + to_nineslice_size[2] + (6 * factor)), (to_nineslice_size[1] + to_nineslice_size[3] + (6 * factor)));
2832

29-
to_image.composite(await image.clone().crop(0, 0, base_nineslice_size[0], base_nineslice_size[1]).borderImage(factor, factor, factor, factor, to_nineslice_size[0], to_nineslice_size[1]), 0, 0);
30-
to_image.composite(await image.clone().crop(base_nineslice_size[0], 0, (image.getWidth() - base_nineslice_size[0] - base_nineslice_size[2]), base_nineslice_size[1]).borderImage(factor, factor, factor, factor, (to_image.getWidth() - to_nineslice_size[0] - to_nineslice_size[2]), to_nineslice_size[1]), to_nineslice_size[0], 0);
31-
to_image.composite(await image.clone().crop((image.getWidth() - base_nineslice_size[2]), 0, base_nineslice_size[2], base_nineslice_size[1]).borderImage(factor, factor, factor, factor, to_nineslice_size[2], to_nineslice_size[1]), (to_image.getWidth() - to_nineslice_size[2]), 0);
33+
to_image.composite(await image.clone().crop(0, 0, base_nineslice_size[0], base_nineslice_size[1]).borderImage((2 * factor), (2 * factor), (2 * factor), (2 * factor), to_nineslice_size[0], to_nineslice_size[1]), 0, 0);
34+
to_image.composite(await image.clone().crop(base_nineslice_size[0], 0, (image.getWidth() - base_nineslice_size[0] - base_nineslice_size[2]), base_nineslice_size[1]).borderImage((2 * factor), (2 * factor), (2 * factor), (2 * factor), (to_image.getWidth() - to_nineslice_size[0] - to_nineslice_size[2]), to_nineslice_size[1]), to_nineslice_size[0], 0);
35+
to_image.composite(await image.clone().crop((image.getWidth() - base_nineslice_size[2]), 0, base_nineslice_size[2], base_nineslice_size[1]).borderImage((2 * factor), (2 * factor), (2 * factor), (2 * factor), to_nineslice_size[2], to_nineslice_size[1]), (to_image.getWidth() - to_nineslice_size[2]), 0);
3236

33-
to_image.composite(await image.clone().crop(0, base_nineslice_size[1], base_nineslice_size[0], (image.getHeight() - base_nineslice_size[1] - base_nineslice_size[3])).borderImage(factor, factor, factor, factor, to_nineslice_size[0], (to_image.getHeight() - to_nineslice_size[1] - to_nineslice_size[3])), 0, to_nineslice_size[1]);
34-
to_image.composite(await image.clone().crop((image.getWidth() - base_nineslice_size[2]), base_nineslice_size[1], base_nineslice_size[2], (image.getHeight() - base_nineslice_size[1] - base_nineslice_size[3])).borderImage(factor, factor, factor, factor, to_nineslice_size[2], (to_image.getHeight() - to_nineslice_size[1] - to_nineslice_size[3])), (to_image.getWidth() - to_nineslice_size[2]), to_nineslice_size[1]);
37+
to_image.composite(await image.clone().crop(0, base_nineslice_size[1], base_nineslice_size[0], (image.getHeight() - base_nineslice_size[1] - base_nineslice_size[3])).borderImage((2 * factor), (2 * factor), (2 * factor), (2 * factor), to_nineslice_size[0], (to_image.getHeight() - to_nineslice_size[1] - to_nineslice_size[3])), 0, to_nineslice_size[1]);
38+
to_image.composite(await image.clone().crop(base_nineslice_size[0], base_nineslice_size[1], (image.getWidth() - base_nineslice_size[0] - base_nineslice_size[2]), (image.getHeight() - base_nineslice_size[1] - base_nineslice_size[3])).borderImage((2 * factor), (2 * factor), (2 * factor), (2 * factor), (to_image.getWidth() - to_nineslice_size[0] - to_nineslice_size[2]), (to_image.getHeight() - to_nineslice_size[1] - to_nineslice_size[3])), to_nineslice_size[0], to_nineslice_size[1]);
39+
to_image.composite(await image.clone().crop((image.getWidth() - base_nineslice_size[2]), base_nineslice_size[1], base_nineslice_size[2], (image.getHeight() - base_nineslice_size[1] - base_nineslice_size[3])).borderImage((2 * factor), (2 * factor), (2 * factor), (2 * factor), to_nineslice_size[2], (to_image.getHeight() - to_nineslice_size[1] - to_nineslice_size[3])), (to_image.getWidth() - to_nineslice_size[2]), to_nineslice_size[1]);
3540

36-
to_image.composite(await image.clone().crop(0, (image.getHeight() - base_nineslice_size[3]), base_nineslice_size[0], base_nineslice_size[2]).borderImage(factor, factor, factor, factor, to_nineslice_size[0], to_nineslice_size[3]), 0, (to_image.getHeight() - to_nineslice_size[3]));
37-
to_image.composite(await image.clone().crop(base_nineslice_size[0], (image.getHeight() - base_nineslice_size[3]), (image.getWidth() - base_nineslice_size[0] - base_nineslice_size[2]), base_nineslice_size[2]).borderImage(factor, factor, factor, factor, (to_image.getWidth() - to_nineslice_size[0] - to_nineslice_size[2]), to_nineslice_size[3]), to_nineslice_size[0], (to_image.getHeight() - to_nineslice_size[3]));
38-
to_image.composite(await image.clone().crop((image.getWidth() - base_nineslice_size[2]), (image.getHeight() - base_nineslice_size[3]), base_nineslice_size[2], base_nineslice_size[2]).borderImage(factor, factor, factor, factor, to_nineslice_size[2], to_nineslice_size[3]), (to_image.getWidth() - to_nineslice_size[2]), (to_image.getHeight() - to_nineslice_size[3]));
41+
to_image.composite(await image.clone().crop(0, (image.getHeight() - base_nineslice_size[3]), base_nineslice_size[0], base_nineslice_size[2]).borderImage((2 * factor), (2 * factor), (2 * factor), (2 * factor), to_nineslice_size[0], to_nineslice_size[3]), 0, (to_image.getHeight() - to_nineslice_size[3]));
42+
to_image.composite(await image.clone().crop(base_nineslice_size[0], (image.getHeight() - base_nineslice_size[3]), (image.getWidth() - base_nineslice_size[0] - base_nineslice_size[2]), base_nineslice_size[2]).borderImage((2 * factor), (2 * factor), (2 * factor), (2 * factor), (to_image.getWidth() - to_nineslice_size[0] - to_nineslice_size[2]), to_nineslice_size[3]), to_nineslice_size[0], (to_image.getHeight() - to_nineslice_size[3]));
43+
to_image.composite(await image.clone().crop((image.getWidth() - base_nineslice_size[2]), (image.getHeight() - base_nineslice_size[3]), base_nineslice_size[2], base_nineslice_size[2]).borderImage((2 * factor), (2 * factor), (2 * factor), (2 * factor), to_nineslice_size[2], to_nineslice_size[3]), (to_image.getWidth() - to_nineslice_size[2]), (to_image.getHeight() - to_nineslice_size[3]));
3944

4045
const metadata = {
41-
nineslice_size: to_nineslice_size,
42-
base_size: [to_image.getWidth(), to_image.getHeight()]
46+
nineslice_size: _to_nineslice_size,
47+
base_size: [(to_image.getWidth() / factor), (to_image.getHeight() / factor)]
4348
};
4449

4550
const to_png = to + ".png";
@@ -58,22 +63,24 @@ class DialogConverter extends AbstractConverter {
5863
*/
5964
static get DEFAULT_CONVERTER_DATA() {
6065
return [
61-
["textures/gui/container/generic_54.png", [
62-
[0, 0, 176, 222, [7, 17, 7, 7], [
63-
["textures/ui/achievements_dialog", [6, 20, 6, 6]],
64-
["textures/ui/dialog_background_hollow_1", [8, 23, 8, 76]],
65-
["textures/ui/dialog_background_hollow_2", [8, 23, 8, 42]],
66-
["textures/ui/dialog_background_hollow_3", [8, 23, 8, 8]],
67-
["textures/ui/dialog_background_hollow_4", [8, 8, 8, 8]],
68-
["textures/ui/dialog_background_hollow_5", [8, 17, 8, 42]],
69-
["textures/ui/dialog_background_hollow_6", [8, 23, 8, 104]],
70-
["textures/ui/dialog_background_hollow_7", [8, 66, 8, 8]],
71-
["textures/ui/dialog_background_hollow_8", [8, 8, 33, 33]],
72-
["textures/ui/dialog_background_opaque", [4, 4, 4, 4]],
73-
["textures/ui/dialog_background_opaque_overlap_bottom", [4, 4, 4, 4]],
74-
["textures/ui/thin_dialog", [6, 6, 6, 6]]
66+
["textures/gui/container/generic_54.png",
67+
256,
68+
[
69+
[0, 0, 176, 222, [7, 17, 7, 7], [
70+
["textures/ui/achievements_dialog", [6, 20, 6, 6]],
71+
["textures/ui/dialog_background_hollow_1", [8, 23, 8, 76]],
72+
["textures/ui/dialog_background_hollow_2", [8, 23, 8, 42]],
73+
["textures/ui/dialog_background_hollow_3", [8, 23, 8, 8]],
74+
["textures/ui/dialog_background_hollow_4", [8, 8, 8, 8]],
75+
["textures/ui/dialog_background_hollow_5", [8, 17, 8, 42]],
76+
["textures/ui/dialog_background_hollow_6", [8, 23, 8, 104]],
77+
["textures/ui/dialog_background_hollow_7", [8, 66, 8, 8]],
78+
["textures/ui/dialog_background_hollow_8", [8, 8, 33, 33]],
79+
["textures/ui/dialog_background_opaque", [4, 4, 4, 4]],
80+
["textures/ui/dialog_background_opaque_overlap_bottom", [4, 4, 4, 4]],
81+
["textures/ui/thin_dialog", [6, 6, 6, 6]]
82+
]]
7583
]]
76-
]]
7784
];
7885
}
7986
}

‎src/converter/PlaceholderConverter.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class PlaceholderConverter extends AbstractConverter {
1818

1919
let image = await this.readImage(from);
2020

21+
image.ensureMinWidth(factor_detect);
22+
2123
const factor = (image.getWidth() / factor_detect);
2224

2325
image.crop((x * factor), (y * factor), (width * factor), (height * factor));

0 commit comments

Comments
 (0)