Added support for blend mode color

This commit is contained in:
Collin Smith 2023-08-06 01:16:44 -07:00
parent bc33e691a0
commit 597835ab08
2 changed files with 107 additions and 2 deletions

View File

@ -280,6 +280,9 @@ public class MpqViewer extends Tool {
VisSlider slFrameDuration;
VisCheckBox cbDebugMode;
VisSelectBox<BlendModes> sbBlendMode;
VisImageButton btnBlendColor;
final Color blendColor = Color.WHITE.cpy();
Texture blendColorTexture;
// Page tab controls
VisLabel lbPage;
@ -815,6 +818,59 @@ public class MpqViewer extends Tool {
setSelectedIndex(0);
setDisabled(true); // disabled -- applied through animation
}}).row();
add(i18n("blendColor")).space(labelSpacing).growX();
final int buttonSize = 22;
if (blendColorTexture != null) blendColorTexture.dispose();
Pixmap p = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
try {
p.drawPixel(0, 0, Color.rgba8888(blendColor));
blendColorTexture = new Texture(p);
} finally {
p.dispose();
}
add(btnBlendColor = new VisImageButton(new VisImageButton.VisImageButtonStyle() {{
imageUp =
imageDown =
imageOver =
imageChecked =
imageCheckedOver =
imageDisabled = new TextureRegionDrawable(blendColorTexture) {{
setMinSize(buttonSize, buttonSize);
}};
}}) {{
addListener(new ClickListener(Input.Buttons.LEFT) {
@Override
public void clicked(InputEvent event, float x, float y) {
ColorPicker cp = new ColorPicker(
i18n("blendColor"),
new ColorPickerAdapter() {
@Override
public void finished(Color newColor) {
blendColor.set(newColor);
if (blendColorTexture != null) blendColorTexture.dispose();
Pixmap p = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
try {
p.drawPixel(0, 0, Color.rgba8888(blendColor));
blendColorTexture = new Texture(p);
getStyle().imageUp =
getStyle().imageDown =
getStyle().imageOver =
getStyle().imageChecked =
getStyle().imageCheckedOver =
getStyle().imageDisabled = new TextureRegionDrawable(blendColorTexture) {{
setMinSize(buttonSize, buttonSize);
}};
} finally {
p.dispose();
}
}
}
);
cp.setColor(blendColor);
stage.addActor(cp.fadeIn());
}
});
}}).left().row();
}}).growX().row();
add(new VisTable() {{
align(topLeft);
@ -1220,6 +1276,7 @@ public class MpqViewer extends Tool {
log.debug("disposing stage...");
stage.dispose();
blendColorTexture.dispose();
log.debug("disposing VisUI...");
VisUI.dispose();
@ -1882,8 +1939,8 @@ public class MpqViewer extends Tool {
String palette = paletteList.getSelected();
Riiablo.batch.setPalette(palettes.get(palette));
log.debug("palette -> {}", palette);
} else if (actor == sbBlendMode) {
anim.getLayer(0).setBlendMode(sbBlendMode.getSelectedIndex());
} else if (actor == sbBlendMode || actor == btnBlendColor) {
anim.getLayer(0).setBlendMode(sbBlendMode.getSelectedIndex(), blendColor);
/*} else if (actor == sbBlendMode) {
int frame = delegate.getFrame();
//if (pages != null) {

View File

@ -0,0 +1,48 @@
mpq-viewer=MPQ Viewer
mpq-viewer-with-file=MPQ Viewer - {0}
menu-file=File
menu-options=Options
menu-open=Open
menu-exit=Exit
menu-check-files=Existing Files Only
menu-custom-listfile=Use External Listfile
address-hint=path...
copy=Copy
copy_as_path=Copy as Path
paste=Paste
filter-hint=filter...
renderer-change-background=Background
renderer-change-background-title=Background Color
renderer-fullscreen=Toggle full screen
renderer-center=Center Camera
animation=Animation
pages=Pages
play-pause=Play/Pause
first-frame=First Frame
prev-frame=Previous Frame
next-frame=Next Frame
last-frame=Last Frame
direction=Direction
direction-label={0,number} / {1,number}
frame=Frame
frame-label={0,number} / {1,number}
speed=Speed
speed-label={0,number} delta
blend=Blend
blendColor=Blend Color
debug-bounds=Debug Bounds
page=Page
page-label={0,number} / {1,number}
palette=Palette
cof=COF
dcc=DCC
dc6=DC6
cof-name=Comp
cof-component=Component
cof-shadow=Shadow
cof-selectable=Selectable
cof-overrideTransLvl=Override Transparency
cof-newTransLvl=New Transparency
cof-weaponClass=Weapon Class
triggers=Triggers
layers=Layers