Skip to content

Commit

Permalink
Added control type "Progress bar" to CHU resource
Browse files Browse the repository at this point in the history
  • Loading branch information
Argent77 committed Oct 5, 2014
1 parent 39d6d21 commit bac1a5d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/infinity/resource/chu/ChuResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected int read(byte buffer[], int offset) throws Exception

offset = windowsoffset.getValue();
int endoffset = offset;
int windowsize = (controlsoffset.getValue() - windowsoffset.getValue()) / numwindows.getValue();
int windowsize = Math.abs(controlsoffset.getValue() - windowsoffset.getValue()) / numwindows.getValue();
for (int i = 0; i < numwindows.getValue(); i++) {
Window window = new Window(this, buffer, offset, i, windowsize);
offset = window.getEndOffset();
Expand Down
33 changes: 24 additions & 9 deletions src/infinity/resource/chu/Control.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@

final class Control extends AbstractStruct // implements AddRemovable
{
private static final String s_type[] = {"Button", "", "Slider", "Text field", "", "Text area",
"Label", "Scroll bar"};
public static final String FMT_NAME = "Control %1$d";

private static final String s_type[] = {"Button", "Progress bar", "Slider", "Text field", "",
"Text area", "Label", "Scroll bar"};
private static final String s_button[] = {"Center", "Left justify", "Right justify",
"Top justify", "Bottom justify", "Anchor",
"Reduce size", "Don't wrap"};
Expand All @@ -31,7 +33,7 @@ final class Control extends AbstractStruct // implements AddRemovable

Control(AbstractStruct superStruct, byte buffer[], int offset, int number) throws Exception
{
super(superStruct, "Control " + number, buffer, offset);
super(superStruct, String.format(FMT_NAME, number), buffer, offset);
}

// --------------------- Begin Interface Writeable ---------------------
Expand Down Expand Up @@ -67,7 +69,7 @@ public int readControl(byte buffer[])
list.add(new Unknown(buffer, offset + 13, 1));

switch (type.getValue()) {
case 0:
case 0: // Button
list.add(new ResourceRef(buffer, offset + 14, "Button", "BAM"));
list.add(new UnsignDecNumber(buffer, offset + 22, 1, "Animation number"));
list.add(new Flag(buffer, offset + 23, 1, "Text flags", s_button));
Expand All @@ -81,7 +83,20 @@ public int readControl(byte buffer[])
list.add(new DecNumber(buffer, offset + 31, 1, "Text anchor: Bottom"));
offset += 32;
break;
case 2:
case 1: // Progress bar
// TODO: find out meaning of data fields
list.add(new ResourceRef(buffer, offset + 14, "Image 1?", "MOS"));
list.add(new ResourceRef(buffer, offset + 22, "Image 2?", "MOS"));
list.add(new ResourceRef(buffer, offset + 30, "Image 2?", "MOS"));
list.add(new DecNumber(buffer, offset + 38, 2, "Number 1?"));
list.add(new DecNumber(buffer, offset + 40, 2, "Number 2?"));
list.add(new DecNumber(buffer, offset + 42, 2, "Number 3?"));
list.add(new DecNumber(buffer, offset + 44, 2, "Number 4?"));
list.add(new DecNumber(buffer, offset + 46, 2, "Number 5?"));
list.add(new DecNumber(buffer, offset + 48, 2, "Number 6?"));
offset += 50;
break;
case 2: // Slider
list.add(new ResourceRef(buffer, offset + 14, "Background image", "MOS"));
list.add(new ResourceRef(buffer, offset + 22, "Slider knob", "BAM"));
list.add(new DecNumber(buffer, offset + 30, 2, "Animation number"));
Expand All @@ -97,7 +112,7 @@ public int readControl(byte buffer[])
list.add(new DecNumber(buffer, offset + 50, 2, "Slider region: Right"));
offset += 52;
break;
case 3:
case 3: // Text field
list.add(new ResourceRef(buffer, offset + 14, "Background 1", "MOS"));
list.add(new ResourceRef(buffer, offset + 22, "Background 2", "MOS"));
list.add(new ResourceRef(buffer, offset + 30, "Background 3", "MOS"));
Expand All @@ -114,7 +129,7 @@ public int readControl(byte buffer[])
list.add(new Bitmap(buffer, offset + 102, 4, "Allowed case", s_case));
offset += 106;
break;
case 5:
case 5: // Text area
list.add(new ResourceRef(buffer, offset + 14, "Font 1", "BAM"));
list.add(new ResourceRef(buffer, offset + 22, "Font 2", "BAM"));
list.add(new Unknown(buffer, offset + 30, 4, "Color 1"));
Expand All @@ -123,15 +138,15 @@ public int readControl(byte buffer[])
list.add(new DecNumber(buffer, offset + 42, 4, "Scroll bar ID"));
offset += 46;
break;
case 6:
case 6: // Label
list.add(new StringRef(buffer, offset + 14, "Initial text"));
list.add(new ResourceRef(buffer, offset + 18, "Font", "BAM"));
list.add(new Unknown(buffer, offset + 26, 4, "Color 1"));
list.add(new Unknown(buffer, offset + 30, 4, "Color 2"));
list.add(new Flag(buffer, offset + 34, 2, "Text flags", s_label));
offset += 36;
break;
case 7:
case 7: // Scroll bar
list.add(new ResourceRef(buffer, offset + 14, "Graphics", "BAM"));
list.add(new DecNumber(buffer, offset + 22, 2, "Animation number"));
list.add(new DecNumber(buffer, offset + 24, 2, "Frame number: Up-arrow, unpressed"));
Expand Down
4 changes: 3 additions & 1 deletion src/infinity/resource/chu/Window.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

final class Window extends AbstractStruct // implements AddRemovable
{
public static final String FMT_NAME = "Panel %1$d";

private static final String hasb[] = {"No", "Yes"};
private static final String s_flag[] = {"No flags set", "Don't dim background"};

Expand All @@ -29,7 +31,7 @@ final class Window extends AbstractStruct // implements AddRemovable

Window(AbstractStruct superStruct, byte buffer[], int offset, int nr, int size) throws Exception
{
super(superStruct, "Panel " + nr, buffer, (size >= 36) ? (offset + 8) : offset);
super(superStruct, String.format(FMT_NAME, nr), buffer, (size >= 36) ? (offset + 8) : offset);
if (size >= 36) {
list.add(0, new TextString(buffer, offset, 8, "Name"));
}
Expand Down

0 comments on commit bac1a5d

Please sign in to comment.