parent
60e76ecfcc
commit
e368877b6e
@ -0,0 +1,43 @@ |
|||||||
|
package mightypork.rogue.init; |
||||||
|
|
||||||
|
|
||||||
|
import mightypork.gamecore.core.App; |
||||||
|
import mightypork.gamecore.core.init.InitTaskScreens; |
||||||
|
import mightypork.gamecore.graphics.Renderable; |
||||||
|
import mightypork.gamecore.gui.screens.ScreenRegistry; |
||||||
|
import mightypork.gamecore.gui.screens.impl.CrossfadeOverlay; |
||||||
|
import mightypork.rogue.RogueStateManager; |
||||||
|
import mightypork.rogue.screens.FpsOverlay; |
||||||
|
import mightypork.rogue.screens.LoadingOverlay; |
||||||
|
import mightypork.rogue.screens.game.ScreenGame; |
||||||
|
import mightypork.rogue.screens.menu.ScreenMainMenu; |
||||||
|
import mightypork.rogue.screens.select_world.ScreenSelectWorld; |
||||||
|
import mightypork.rogue.screens.story.ScreenStory; |
||||||
|
import mightypork.rogue.world.WorldProvider; |
||||||
|
|
||||||
|
|
||||||
|
public class InitScreens extends InitTaskScreens { |
||||||
|
|
||||||
|
@Override |
||||||
|
protected Renderable getMainRenderableImpl() |
||||||
|
{ |
||||||
|
final ScreenRegistry screens = new ScreenRegistry(); |
||||||
|
app.addChildClient(screens); |
||||||
|
|
||||||
|
/* game screen references world provider instance */ |
||||||
|
App.bus().subscribe(new RogueStateManager()); |
||||||
|
App.bus().subscribe(WorldProvider.get()); |
||||||
|
|
||||||
|
screens.addOverlay(new CrossfadeOverlay()); |
||||||
|
|
||||||
|
screens.addScreen("main_menu", new ScreenMainMenu()); |
||||||
|
screens.addScreen("select_world", new ScreenSelectWorld()); |
||||||
|
screens.addScreen("game", new ScreenGame()); |
||||||
|
screens.addScreen("story", new ScreenStory()); |
||||||
|
|
||||||
|
screens.addOverlay(new FpsOverlay()); |
||||||
|
screens.addOverlay(new LoadingOverlay()); |
||||||
|
|
||||||
|
return screens; |
||||||
|
} |
||||||
|
} |
@ -1,11 +1,11 @@ |
|||||||
package mightypork.rogue; |
package mightypork.rogue.init; |
||||||
|
|
||||||
|
|
||||||
import mightypork.gamecore.core.config.Config; |
import mightypork.gamecore.core.config.Config; |
||||||
import mightypork.gamecore.core.config.InitTaskConfig; |
import mightypork.gamecore.core.config.InitTaskConfig; |
||||||
|
|
||||||
|
|
||||||
public class RogueInitConfig extends InitTaskConfig { |
public class SetupConfig extends InitTaskConfig { |
||||||
|
|
||||||
@Override |
@Override |
||||||
protected Config buildConfig() |
protected Config buildConfig() |
@ -0,0 +1,25 @@ |
|||||||
|
package mightypork.rogue.init; |
||||||
|
|
||||||
|
|
||||||
|
import mightypork.gamecore.core.App; |
||||||
|
import mightypork.gamecore.core.init.InitTaskDisplay; |
||||||
|
import mightypork.rogue.Const; |
||||||
|
|
||||||
|
|
||||||
|
public class SetupDisplay extends InitTaskDisplay { |
||||||
|
|
||||||
|
@Override |
||||||
|
public void init() |
||||||
|
{ |
||||||
|
final int w = App.cfg().getValue("display.width"); |
||||||
|
final int h = App.cfg().getValue("display.height"); |
||||||
|
final boolean fs = App.cfg().getValue("display.fullscreen"); |
||||||
|
|
||||||
|
setSize(w, h); |
||||||
|
setResizable(true); |
||||||
|
setFullscreen(fs); |
||||||
|
setTitle(Const.TITLEBAR); |
||||||
|
setTargetFps(Const.FPS_RENDER); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,60 @@ |
|||||||
|
package mightypork.rogue.init; |
||||||
|
|
||||||
|
|
||||||
|
import mightypork.gamecore.core.App; |
||||||
|
import mightypork.gamecore.core.init.InitTask; |
||||||
|
import mightypork.gamecore.core.plugins.screenshot.ScreenshotRequest; |
||||||
|
import mightypork.gamecore.graphics.FullscreenToggleRequest; |
||||||
|
import mightypork.gamecore.input.Trigger; |
||||||
|
import mightypork.utils.eventbus.BusEvent; |
||||||
|
|
||||||
|
|
||||||
|
public class SetupGlobalKeys extends InitTask { |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public void run() |
||||||
|
{ |
||||||
|
bindEventToKey(new FullscreenToggleRequest(), "global.fullscreen"); |
||||||
|
bindEventToKey(new ScreenshotRequest(), "global.screenshot"); |
||||||
|
|
||||||
|
final Runnable quitTask = new Runnable() { |
||||||
|
|
||||||
|
@Override |
||||||
|
public void run() |
||||||
|
{ |
||||||
|
App.shutdown(); |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
App.input().bindKey(App.cfg().getKeyStroke("global.quit"), Trigger.RISING, quitTask); |
||||||
|
App.input().bindKey(App.cfg().getKeyStroke("global.quit_force"), Trigger.RISING, quitTask); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private void bindEventToKey(final BusEvent<?> event, String strokeName) |
||||||
|
{ |
||||||
|
App.input().bindKey(App.cfg().getKeyStroke(strokeName), Trigger.RISING, new Runnable() { |
||||||
|
|
||||||
|
@Override |
||||||
|
public void run() |
||||||
|
{ |
||||||
|
App.bus().send(event); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public String getName() |
||||||
|
{ |
||||||
|
return "global_keys"; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public String[] getDependencies() |
||||||
|
{ |
||||||
|
return new String[] { "config" }; |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue