update mindow

This commit is contained in:
sharlottes
2022-06-20 18:28:58 +09:00
parent 10188b9ebb
commit 9974df2012
2 changed files with 11 additions and 3 deletions

View File

@@ -229,10 +229,10 @@ public class UnitWindow extends Window {
Draw.color(Color.white);
Draw.alpha(parentAlpha * color.a);
BarInfo.BarData data = BarInfo.data.get(index);
getDrawable().draw(x, y, width, height);
data.icon.draw(x, y, width, height);
if (!hasMouse() && ScissorStack.push(Tmp.r1.set(ScissorStack.peek().x + x, ScissorStack.peek().y + y, width, height * data.number))) {
Draw.color(data.color);
getDrawable().draw(x, y, width, height);
data.icon.draw(x, y, width, height);
ScissorStack.pop();
}
}
@@ -245,7 +245,7 @@ public class UnitWindow extends Window {
@Override
public void exit(InputEvent event, float x, float y, int pointer, Element fromActor){
icon.setDrawable(BarInfo.data.get(index).icon);
icon.setDrawable(BarInfo.data.size >= index ? Icon.none : BarInfo.data.get(index).icon);
}
});
icon.clicked(()->{

View File

@@ -44,6 +44,14 @@ public class Window extends Table {
id = WindowManager.register(this);
visible(() -> shown);
update(() -> {
if(x > Core.graphics.getWidth() - getWidth()/2) setPosition(Core.graphics.getWidth() - getWidth()/2, y);
else if(x < -getWidth()/2) setPosition(-getWidth()/2, y);
if(y > Core.graphics.getHeight() - getHeight()/2) setPosition(x, Core.graphics.getHeight() - getHeight()/2);
else if(y < -getHeight()/2) setPosition(x, -getHeight()/2);
});
}
protected void build(Table t){