Skip to content

Commit

Permalink
update questionMarkIcon as SecondaryInfoBoardCaller
Browse files Browse the repository at this point in the history
  • Loading branch information
hundun000 committed Oct 21, 2023
1 parent a061fb2 commit 5fb4c9d
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 23 deletions.
Binary file added IdleMushroom-game/core/assets/All Icons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,20 @@

import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable;
import hundun.gdxgame.idleshare.core.framework.model.manager.AbstractTextureManager;
import lombok.Getter;

public class IdleMushroomTextureManager extends AbstractTextureManager {

@Getter
TextureRegion questionMarkTexture;

@Override
public void lazyInitOnGameCreateStage2() {
{
Texture texture = new Texture(Gdx.files.internal("All Icons.png"));
TextureRegion[][] regions = TextureRegion.split(texture, 16, 16);
questionMarkTexture = regions[0][13];
}

achievementMaskBoardTexture = new Texture(Gdx.files.internal("win.png"));
menuTexture = new Texture(Gdx.files.internal("menu.png"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.Touchable;
import com.badlogic.gdx.scenes.scene2d.ui.*;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.utils.Align;
Expand All @@ -16,6 +15,7 @@
import hundun.gdxgame.gamelib.starter.listerner.ILogicFrameListener;
import hundun.gdxgame.idledemo.logic.DemoConstructionPrototypeId;
import hundun.gdxgame.idledemo.ui.screen.BaseDemoPlayScreen;
import hundun.gdxgame.idledemo.ui.screen.MainPlayScreen;
import hundun.gdxgame.idledemo.ui.shared.BaseCellDetailNodeVM;
import hundun.gdxgame.idledemo.ui.shared.ConstructionDetailPartVM;
import hundun.gdxgame.idleshare.core.starter.ui.component.board.construction.impl.StarterConstructionControlNode;
Expand All @@ -38,13 +38,13 @@ public class MainScreenConstructionControlBoard extends Table
implements ILogicFrameListener, IGameAreaChangeListener, IConstructionCollectionListener
{

BaseDemoPlayScreen parent;
MainPlayScreen parent;
protected ISecondaryInfoBoardCallback<BaseConstruction> callback;

protected SellerPart sellerPart;
protected EpochPart epochPart;
protected ConstructionDetailPartVM epochDetailPart;
public MainScreenConstructionControlBoard(BaseDemoPlayScreen parent, ISecondaryInfoBoardCallback<BaseConstruction> callback) {
public MainScreenConstructionControlBoard(MainPlayScreen parent, ISecondaryInfoBoardCallback<BaseConstruction> callback) {
this.parent = parent;
this.callback = callback;

Expand Down Expand Up @@ -107,7 +107,7 @@ public void onConstructionCollectionChange() {
}

public static class EpochPart extends BaseCellDetailNodeVM {
BaseDemoPlayScreen parent;
MainPlayScreen parent;
BaseConstruction model;
Label constructionNameLabel;

Expand All @@ -119,13 +119,13 @@ public static class EpochPart extends BaseCellDetailNodeVM {


public EpochPart(
BaseDemoPlayScreen parent,
MainPlayScreen parent,
ISecondaryInfoBoardCallback<BaseConstruction> callback) {
super();
final PlayScreenLayoutConst playScreenLayoutConst = parent.getLayoutConst();
this.parent = parent;

int CHILD_WIDTH = playScreenLayoutConst.CONSTRUCION_CHILD_WIDTH;
int CHILD_WIDTH = playScreenLayoutConst.EPOCH_PART_CHILD_WIDTH;
int CHILD_HEIGHT = playScreenLayoutConst.CONSTRUCION_CHILD_BUTTON_HEIGHT;
int NAME_CHILD_HEIGHT = playScreenLayoutConst.CONSTRUCION_CHILD_NAME_HEIGHT;

Expand All @@ -143,17 +143,20 @@ public void changed(ChangeEvent event, Actor actor) {
}
});

// ------ changeWorkingLevelGroup ------

this.workingLevelLabel = new Label("", parent.getGame().getMainSkin());
workingLevelLabel.setAlignment(Align.center);

Container<?> questionMarkArea = new Container<>(new Image(parent.getGame().getIdleMushroomTextureManager().getQuestionMarkTexture()));
questionMarkArea.setBackground(parent.getGame().getIdleMushroomTextureManager().getDefaultBoardNinePatchDrawable());
questionMarkArea.setTouchable(Touchable.enabled);
questionMarkArea.addListener(new StarterSecondaryInfoBoardCallerClickListener(() -> model, parent));

// ------ this ------
this.add(constructionNameLabel).size(CHILD_WIDTH, NAME_CHILD_HEIGHT).row();
this.add(questionMarkArea).height(CHILD_HEIGHT).row();
this.add(upgradeButton).size(CHILD_WIDTH, CHILD_HEIGHT).row();
this.add(workingLevelLabel).size(CHILD_WIDTH, CHILD_HEIGHT).row();
this.setBackground(DrawableFactory.createBorderBoard(30, 10, 0.8f, 1));
this.addListener(new StarterSecondaryInfoBoardCallerClickListener(model, callback));
}

private void update() {
Expand Down Expand Up @@ -205,7 +208,7 @@ public void subLogicFrame() {
}

public static class SellerPart extends BaseCellDetailNodeVM {
BaseDemoPlayScreen parent;
MainPlayScreen parent;
BaseConstruction model;
Label constructionNameLabel;
TextButton upWorkingLevelButton;
Expand All @@ -221,13 +224,13 @@ public static class SellerPart extends BaseCellDetailNodeVM {


public SellerPart(
BaseDemoPlayScreen parent,
MainPlayScreen parent,
ISecondaryInfoBoardCallback<BaseConstruction> callback) {
super();
final PlayScreenLayoutConst playScreenLayoutConst = parent.getLayoutConst();
this.parent = parent;

int CHILD_WIDTH = playScreenLayoutConst.CONSTRUCION_CHILD_WIDTH;
int CHILD_WIDTH = playScreenLayoutConst.SELLER_PART_CHILD_WIDTH;
int CHILD_HEIGHT = playScreenLayoutConst.CONSTRUCION_CHILD_BUTTON_HEIGHT;
int NAME_CHILD_HEIGHT = playScreenLayoutConst.CONSTRUCION_CHILD_NAME_HEIGHT;

Expand Down Expand Up @@ -273,15 +276,21 @@ public void clicked(InputEvent event, float x, float y) {
detailGroup = new Table();

this.transformButton = new TextButton("-", parent.getGame().getMainSkin());

Container<?> questionMarkArea = new Container<>(new Image(parent.getGame().getIdleMushroomTextureManager().getQuestionMarkTexture()));
questionMarkArea.setBackground(parent.getGame().getIdleMushroomTextureManager().getDefaultBoardNinePatchDrawable());
questionMarkArea.setTouchable(Touchable.enabled);
questionMarkArea.addListener(new StarterSecondaryInfoBoardCallerClickListener(() -> model, parent));

// ------ this ------
this.add(constructionNameLabel).size(CHILD_WIDTH, NAME_CHILD_HEIGHT).row();
this.add(questionMarkArea).height(CHILD_HEIGHT).row();
this.add(upgradeButton).size(CHILD_WIDTH, CHILD_HEIGHT).row();
this.add(workingLevelLabel).size(CHILD_WIDTH, CHILD_HEIGHT).row();
this.add(changeWorkingLevelGroup).size(CHILD_WIDTH, CHILD_HEIGHT).row();
this.add(detailGroup).row();

this.setBackground(DrawableFactory.createBorderBoard(30, 10, 0.8f, 1));
this.addListener(new StarterSecondaryInfoBoardCallerClickListener(model, callback));
}

private void update() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import hundun.gdxgame.idleshare.gamelib.framework.callback.ISecondaryInfoBoardCallback;
import hundun.gdxgame.idleshare.gamelib.framework.model.construction.base.BaseConstruction;

import java.util.function.Supplier;


/**
* @author hundun
Expand All @@ -42,26 +44,26 @@ public class StarterConstructionControlNode<T_GAME extends BaseIdleGame<T_SAVE>,
Table changeWorkingLevelGroup;

public static class StarterSecondaryInfoBoardCallerClickListener extends ClickListener {
BaseConstruction model;
Supplier<BaseConstruction> modelGetter;
ISecondaryInfoBoardCallback<BaseConstruction> callback;

public StarterSecondaryInfoBoardCallerClickListener(BaseConstruction model, ISecondaryInfoBoardCallback<BaseConstruction> callback) {
this.model = model;
public StarterSecondaryInfoBoardCallerClickListener(Supplier<BaseConstruction> modelGetter, ISecondaryInfoBoardCallback<BaseConstruction> callback) {
this.modelGetter = modelGetter;
this.callback = callback;
}
@Override
public void clicked(InputEvent event, float x, float y) {
if (model != null) {
callback.showAndUpdateGuideInfo(model);
if (modelGetter.get() != null) {
callback.showAndUpdateGuideInfo(modelGetter.get());
}
Gdx.app.log(StarterConstructionControlNode.class.getSimpleName(), "this clicked event");
super.clicked(event, x, y);
}

@Override
public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) {
if (model != null && pointer == -1) {
callback.showAndUpdateGuideInfo(model);
if (modelGetter.get() != null && pointer == -1) {
callback.showAndUpdateGuideInfo(modelGetter.get());
}
super.enter(event, x, y, pointer, fromActor);
}
Expand Down Expand Up @@ -109,7 +111,7 @@ public void changed(ChangeEvent event, Actor actor) {
}
});

this.addListener(new StarterSecondaryInfoBoardCallerClickListener(model, callback));
this.addListener(new StarterSecondaryInfoBoardCallerClickListener(() -> model, callback));

// ------ changeWorkingLevelGroup ------
this.changeWorkingLevelGroup = new Table();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
* Created on 2022/01/22
*/
public class PlayScreenLayoutConst {
public static final int EPOCH_PART_CHILD_WIDTH = 200;
public static final int SELLER_PART_CHILD_WIDTH = 200;
public final float DESK_WIDTH = 100;
public final float DESK_HEIGHT = 100;
public int CONSTRUCION_BOARD_ROOT_BOX_HEIGHT = 200;
Expand Down

0 comments on commit 5fb4c9d

Please sign in to comment.