-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
189 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
IdleDemo-game/core/src/main/java/hundun/gdxgame/idledemo/ui/world/BaseCellDetailBoardVM.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package hundun.gdxgame.idledemo.ui.world; | ||
|
||
import com.badlogic.gdx.scenes.scene2d.ui.Image; | ||
import com.badlogic.gdx.scenes.scene2d.ui.Table; | ||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; | ||
import hundun.gdxgame.gamelib.starter.listerner.ILogicFrameListener; | ||
import hundun.gdxgame.idledemo.ui.screen.BaseDemoPlayScreen; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class BaseCellDetailBoardVM extends Table implements ILogicFrameListener { | ||
protected BaseDemoPlayScreen parent; | ||
|
||
|
||
|
||
protected List<CellDetailInnerBoardVM> contents = new ArrayList<>(); | ||
|
||
public void onLogicFrame() | ||
{ | ||
contents.forEach(it -> { | ||
it.update(); | ||
}); | ||
} | ||
|
||
public void postPrefabInitialization(BaseDemoPlayScreen parent) | ||
{ | ||
//super("GUIDE_TEXT", parent.game.getButtonSkin()); | ||
this.parent = parent; | ||
this.setBackground(new TextureRegionDrawable(parent.getGame().getTextureManager().getDefaultBoardNinePatchTexture())); | ||
|
||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...Demo-game/core/src/main/java/hundun/gdxgame/idledemo/ui/world/CellDetailInnerBoardVM.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package hundun.gdxgame.idledemo.ui.world; | ||
|
||
import com.badlogic.gdx.scenes.scene2d.ui.Label; | ||
import com.badlogic.gdx.scenes.scene2d.ui.Table; | ||
import hundun.gdxgame.idledemo.ui.screen.BaseDemoPlayScreen; | ||
import hundun.gdxgame.idleshare.gamelib.framework.model.construction.AbstractConstructionPrototype; | ||
import hundun.gdxgame.idleshare.gamelib.framework.model.construction.base.BaseConstruction; | ||
import hundun.gdxgame.idleshare.gamelib.framework.model.grid.GridPosition; | ||
|
||
public class CellDetailInnerBoardVM extends Table { | ||
|
||
Label label; | ||
|
||
public void postPrefabInitialization(BaseDemoPlayScreen parent) { | ||
label = new Label("", parent.getGame().getMainSkin()); | ||
this.add(label); | ||
} | ||
|
||
public void update() { | ||
|
||
} | ||
|
||
|
||
public void update(BaseConstruction construction, GridPosition position) { | ||
label.setText("construction: " + construction.getName()); | ||
} | ||
|
||
public void update(AbstractConstructionPrototype constructionPrototype, GridPosition position) { | ||
label.setText("constructionPrototype: " + constructionPrototype.getPrototypeId()); | ||
} | ||
} |
93 changes: 93 additions & 0 deletions
93
...Demo-game/core/src/main/java/hundun/gdxgame/idledemo/ui/world/WorldCellDetailBoardVM.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package hundun.gdxgame.idledemo.ui.world; | ||
|
||
import com.badlogic.gdx.scenes.scene2d.ui.Table; | ||
import hundun.gdxgame.idledemo.logic.ConstructionPrototypeId; | ||
import hundun.gdxgame.idledemo.ui.screen.ForestPlayScreen; | ||
import hundun.gdxgame.idleshare.gamelib.framework.callback.IConstructionCollectionListener; | ||
import hundun.gdxgame.idleshare.gamelib.framework.model.construction.AbstractConstructionPrototype; | ||
import hundun.gdxgame.idleshare.gamelib.framework.model.construction.base.BaseConstruction; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
import java.util.List; | ||
|
||
public class WorldCellDetailBoardVM extends BaseCellDetailBoardVM implements IConstructionCollectionListener { | ||
@Getter | ||
@Setter | ||
public BaseConstruction data; | ||
|
||
|
||
public WorldCellDetailBoardVM(ForestPlayScreen parent) | ||
{ | ||
super.postPrefabInitialization(parent); | ||
updateDetail(null); | ||
} | ||
|
||
public void updateDetail(BaseConstruction construction) | ||
{ | ||
this.data = construction; | ||
if (construction == null) | ||
{ | ||
updateAsEmpty(); | ||
return; | ||
} | ||
|
||
switch (construction.getPrototypeId()) | ||
{ | ||
case ConstructionPrototypeId.DIRT: | ||
updateAsConstructionPrototypeDetail(construction); | ||
break; | ||
default: | ||
updateAsConstructionDetail(construction); | ||
break; | ||
} | ||
} | ||
private void updateAsEmpty() | ||
{ | ||
this.clearChildren(); | ||
contents.clear(); | ||
} | ||
|
||
private void updateAsConstructionDetail(BaseConstruction construction) | ||
{ | ||
this.clearChildren(); | ||
contents.clear(); | ||
|
||
CellDetailInnerBoardVM innerBoardVM = new CellDetailInnerBoardVM(); | ||
innerBoardVM.postPrefabInitialization(parent); | ||
innerBoardVM.update(construction, construction.getSaveData().getPosition()); | ||
this.add(innerBoardVM); | ||
contents.add(innerBoardVM); | ||
|
||
} | ||
|
||
private void updateAsConstructionPrototypeDetail(BaseConstruction construction) | ||
{ | ||
this.clearChildren(); | ||
contents.clear(); | ||
|
||
List<AbstractConstructionPrototype> constructionPrototypes = parent.getGame().getIdleGameplayExport() | ||
.getGameplayContext() | ||
.getConstructionManager() | ||
.getAreaShownConstructionPrototypesOrEmpty(parent.getArea()); | ||
|
||
constructionPrototypes.forEach(constructionPrototype -> { | ||
CellDetailInnerBoardVM innerBoardVM = new CellDetailInnerBoardVM(); | ||
innerBoardVM.postPrefabInitialization(parent); | ||
innerBoardVM.update(constructionPrototype, construction.getSaveData().getPosition()); | ||
this.add(innerBoardVM); | ||
contents.add(innerBoardVM); | ||
}); | ||
|
||
} | ||
|
||
@Override | ||
public void onConstructionCollectionChange() | ||
{ | ||
if (data != null) | ||
{ | ||
data = parent.getGame().getIdleGameplayExport().getGameplayContext().getConstructionManager().getConstructionAt(data.getPosition()); | ||
updateDetail(data); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters