-
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
Meshulam Silk
committed
Nov 24, 2013
1 parent
3871b13
commit 6fd3151
Showing
6 changed files
with
151 additions
and
3 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
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,51 @@ | ||
package com.moomoohk.Grame.commands; | ||
|
||
import java.util.ArrayList; | ||
|
||
import com.moomoohk.Grame.Essentials.GrameManager; | ||
import com.moomoohk.Grame.test.Dialog; | ||
import com.moomoohk.MooCommands.Command; | ||
|
||
public class ShowDialogCommand extends Command | ||
{ | ||
|
||
@Override | ||
public String getCommand() | ||
{ | ||
return "dialog"; | ||
} | ||
|
||
@Override | ||
public String getHelpMessage() | ||
{ | ||
return "DEBUG: Prints some dialog on a speecified Grame Object"; | ||
} | ||
|
||
@Override | ||
public String getUsage() | ||
{ | ||
return "dialog <go ID>"; | ||
} | ||
|
||
@Override | ||
public int getMaxParams() | ||
{ | ||
return 1; | ||
} | ||
|
||
@Override | ||
public int getMinParams() | ||
{ | ||
return 1; | ||
} | ||
|
||
@Override | ||
protected void execute(String[] params) | ||
{ | ||
ArrayList<String> lines = new ArrayList<String>(); | ||
lines.add("My name is Inigo Montoya"); | ||
lines.add("You killed my father"); | ||
lines.add("Prepare to die"); | ||
new Dialog(lines, 5000, GrameManager.findGrameObject(Integer.parseInt(params[0]))).start(); | ||
} | ||
} |
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,70 @@ | ||
package com.moomoohk.Grame.test; | ||
|
||
import java.awt.Color; | ||
import java.util.ArrayList; | ||
|
||
import com.moomoohk.Grame.Essentials.Coordinates; | ||
import com.moomoohk.Grame.Essentials.GrameManager; | ||
import com.moomoohk.Grame.Graphics.RenderManager; | ||
import com.moomoohk.Grame.Graphics.PostProcessing.Label; | ||
import com.moomoohk.Grame.Interfaces.GrameObject; | ||
|
||
public class Dialog implements Runnable | ||
{ | ||
private ArrayList<String> lines; | ||
private Label label; | ||
private long interval; | ||
private GrameObject go; | ||
|
||
public Dialog(ArrayList<String> lines, long interval, GrameObject go) | ||
{ | ||
this.label = new Label(); | ||
this.label.setBackColor(Color.black); | ||
this.label.setTextColor(Color.white); | ||
this.label.setPadding(10); | ||
this.lines = lines; | ||
this.interval = interval; | ||
this.go = go; | ||
RenderManager.addLabel(this.label); | ||
} | ||
|
||
public void start() | ||
{ | ||
new Thread(this).start(); | ||
} | ||
|
||
@Override | ||
public void run() | ||
{ | ||
GrameManager.pauseAllGrameObjects(true); | ||
int squareWidth = RenderManager.getMainCanvas().getWidth() / GrameManager.findBase(RenderManager.getMainBase()).getColumns(), squareHeight = RenderManager.getMainCanvas().getHeight() / GrameManager.findBase(RenderManager.getMainBase()).getRows(); | ||
Coordinates goPos = this.go.getPos(RenderManager.getMainBase()); | ||
this.label.setCenterX(Math.max(50, goPos.getX() * squareWidth + squareWidth / 2)); | ||
this.label.setCenterY(Math.max(50, goPos.getY() * squareHeight)); | ||
for (String line : this.lines) | ||
{ | ||
for (int i = 0; i <= line.length(); i++) | ||
{ | ||
this.label.setText(line.substring(0, i)); | ||
try | ||
{ | ||
Thread.sleep(50); | ||
} | ||
catch (Exception e) | ||
{ | ||
e.printStackTrace(); | ||
} | ||
} | ||
try | ||
{ | ||
Thread.sleep(this.interval); | ||
} | ||
catch (Exception e) | ||
{ | ||
e.printStackTrace(); | ||
} | ||
} | ||
RenderManager.removeLabel(this.label); | ||
GrameManager.pauseAllGrameObjects(false); | ||
} | ||
} |