Skip to content

Commit

Permalink
1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
szatkus committed May 2, 2014
1 parent 81d08c0 commit 8184d30
Show file tree
Hide file tree
Showing 12 changed files with 113 additions and 76 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ Milestone 0.8
* Run Courage the Coward Dog (done)
* App (**rejected**)

Milestone 0.9
* Run Ginger
* Run JaduGadu
* Priviliged app (fuck!, looks like we need two versions of app)
* Rewrite the compiler... two times, with JIT (master branch) and as interpreter (privileged branch)
* Make forms work perfectly, with nice tests and candies
Milestone 1.0
* Run Ginger (done)
* Run JaduGadu (no, this doesn't work anyway)
* Priviliged app (fuck!, looks like we need two versions of app) (done)
* Rewrite the compiler... two times, with JIT (master branch) and as interpreter (privileged branch) (1/2)
* Make forms work perfectly, with nice tests and candies (naaahh, too lazy)

Milestone X

Expand Down
19 changes: 13 additions & 6 deletions css/emulator.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,22 @@ html, body {
}
#keypad {
text-align: center;
position: relative;
}
.key, .softkey, #joypad {
font-size: 6mm;
cursor: pointer;
margin: 1px;
height: 10mm;
line-height: 10mm;
}
.softkey {
width: 30%;
}
#joypad {
width: 30%;
}

.num {
width: 30%;
padding-top: 1px;
}

#frame {
display: inline-block;
overflow: hidden;
Expand All @@ -67,7 +65,7 @@ html, body {
overflow: auto;
}

#screen canvas {
#screen > canvas {
height: 100%;
max-width: 100%;
margin: auto;
Expand Down Expand Up @@ -183,3 +181,12 @@ html, body {
color: #333;
font-size: 4mm;
}

#keypad #joypad {
position: absolute;
width: 100%;
height: 32mm;
top: -35mm;
left: 0;
opacity: 0.4;
}
12 changes: 10 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,20 @@
</div>
<button class="topbutton" id="settings-button">i</button>
<div id="screen">
<div id="jar-list"></div>
<div id="jar-list">No JARs found on SD card</div>
</div>
<div id="keypad">
<div id="joypad">
<button id="up" class="key num">&nbsp;</button><br>
<button id="left" class="key num">&nbsp;</button>
<button id="ok" class="key num">&nbsp;</button>
<button id="right" class="key num">&nbsp;</button><br>
<button id="down" class="key num">&nbsp;</button>
</div>


<button id="choice" class="softkey">&nbsp;</button>
<button id="joypad" class="key">&nbsp;</button>
<button id="open-joypad" class="key">&nbsp;</button>
<button id="back" class="softkey">&nbsp;</button><br>

<button id="num1" class="key num">1</button>
Expand Down
35 changes: 27 additions & 8 deletions js/emulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
mapping[88] = -7;
mapping[90] = -6;
document.onkeydown = function (e) {
//console.log(e.which);
console.log(e.which);
if (mapping[e.which]) {
js2me.sendKeyPressEvent(mapping[e.which]);
}
Expand All @@ -36,6 +36,8 @@
var settingsDialog = document.getElementById('settings');
var screenSizeSelector = document.querySelector('select.screen-size');
var generateMethodsButton = document.querySelector('button.generate-methods');
var joypad = document.getElementById('joypad');
joypad.style.display = 'none';
document.getElementById('settings-button').addEventListener('click', function () {
settingsDialog.style.top = 0;
var screenSize = loadConfig('width') + ',';
Expand All @@ -49,6 +51,14 @@
}
generateMethodsButton.disabled = (js2me.manifest == null);
});
document.getElementById('open-joypad').addEventListener('click', function () {

if (joypad.style.display === 'none') {
joypad.style.display = '';
} else {
joypad.style.display = 'none';
}
});
generateMethodsButton.addEventListener('click', function () {
generateMethodsButton.innerHTML = 'Please wait...';
generateMethodsButton.classList.add('disabled');
Expand All @@ -69,6 +79,11 @@
js2me.sendKeyReleasedEvent();
});
var buttonsMapping = {
up: -1,
down: -2,
left: -3,
right: -4,
ok: -5,
choice: -6,
back: -7,
num1: 49,
Expand Down Expand Up @@ -156,21 +171,25 @@
var jarList = document.getElementById('jar-list');
var storage = navigator.getDeviceStorage('sdcard');
var cursor = storage.enumerate();

var isClearList = true;
cursor.onsuccess = function () {
if (this.result.name.lastIndexOf('.jar') === this.result.name.length - 4) {
if (isClearList) {
isClearList = false;
jarList.innerHTML = '';
}
var file = this.result;
var item = document.createElement('div');
item.className = 'item';
item.innerHTML = file.name.substring(file.name.lastIndexOf('/') + 1)
item.addEventListener('click', function () {
js2me.loadJAR(file, function () {
document.getElementById('screen').innerHTML = '';
loadConfig('width');
loadConfig('height');
loadConfig('fullHeight');
js2me.launchMidlet(1);
});
document.getElementById('screen').innerHTML = '';
loadConfig('width');
loadConfig('height');
loadConfig('fullHeight');
js2me.launchMidlet(1);
});
});
jarList.appendChild(item);
}
Expand Down
3 changes: 3 additions & 0 deletions js/me/java/lang/Byte.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ js2me.createClass({
*/
_init$B$V: function (value) {
this.value = value;
},
$byteValue$$B: function () {
return this.value;
}
});
19 changes: 19 additions & 0 deletions js/me/javax/microedition/lcdui/Alert.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
js2me.createClass({
construct: function () {
var alert = this;
this.commandListener = {
$commandAction$Ljavax_microedition_lcdui_Command_Ljavax_microedition_lcdui_Displayable_$V: function () {
alert.display.$setCurrent$Ljavax_microedition_lcdui_Displayable_$V(alert.display.lastDisplayable);
}
};
},
/*
* public Alert(String title)
*/
Expand Down Expand Up @@ -26,6 +34,17 @@ js2me.createClass({
console.log('show?');
}, time);
},
refreshCommands: function () {
if (this.commands.length === 0) {
var dismissCommand = new javaRoot.$javax.$microedition.$lcdui.$Command();
dismissCommand._init$Ljava_lang_String_II$V(new javaRoot.$java.$lang.$String('OK'), javaRoot.$javax.$microedition.$lcdui.$Command.prototype.$OKI, 0);
this.commands = [dismissCommand];
javaRoot.$javax.$microedition.$lcdui.$Screen.prototype.refreshCommands.apply(this, arguments);
this.commands = [];
} else {
javaRoot.$javax.$microedition.$lcdui.$Screen.prototype.refreshCommands.apply(this, arguments);
}
},
superClass: 'javaRoot.$javax.$microedition.$lcdui.$Screen'
});

Expand Down
33 changes: 33 additions & 0 deletions js/me/javax/microedition/lcdui/Display.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,38 @@ js2me.createClass({
midlet.display = new javaRoot.$javax.$microedition.$lcdui.$Display();
var element = document.getElementById('screen');
midlet.display.element = element;
this.choiceButton = document.getElementById('choice');
this.backButton = document.getElementById('back');
this.choiceButton.addEventListener('mousedown', function () {
var displayable = midlet.display.current;
var moreMenuListener = {
$commandAction$Ljavax_microedition_lcdui_Command_Ljavax_microedition_lcdui_Displayable_$V: function () {
var command = displayable.currentCommands[displayable.moreList.$getSelectedIndex$$I()];
displayable.display.$setCurrent$Ljavax_microedition_lcdui_Displayable_$V(displayable);
displayable.commandListener.$commandAction$Ljavax_microedition_lcdui_Command_Ljavax_microedition_lcdui_Displayable_$V(command, displayable);
}
};
if (displayable && displayable.commandListener) {
displayable.currentCommands = displayable.choiceCommands;
if (displayable.choiceCommands.length == 1) {
displayable.commandListener.$commandAction$Ljavax_microedition_lcdui_Command_Ljavax_microedition_lcdui_Displayable_$V(displayable.choiceCommands[0], displayable);
}
if (displayable.choiceCommands.length > 1) {
displayable.display.$setCurrent$Ljavax_microedition_lcdui_Displayable_$V(displayable.moreList);
displayable.moreList.$setCommandListener$Ljavax_microedition_lcdui_CommandListener_$V(moreMenuListener);
displayable.moreList.$deleteAll$$V();
for (var i = 0; i < displayable.currentCommands.length; i++) {
displayable.moreList.$append$Ljava_lang_String_Ljavax_microedition_lcdui_Image_$I(displayable.currentCommands[i].label, null);
}
}
}
});
this.backButton.addEventListener('mousedown', function () {
var displayable = midlet.display.current;
if (displayable && displayable.backCommands.length == 1 && displayable.commandListener) {
displayable.commandListener.$commandAction$Ljavax_microedition_lcdui_Command_Ljavax_microedition_lcdui_Displayable_$V(displayable.backCommands[0], displayable);
}
});
}
return midlet.display;
},
Expand All @@ -19,6 +51,7 @@ js2me.createClass({
if (this.current) {
this.current.active = false;
}
this.lastDisplayable = this.current;
this.current = displayable;
if (displayable != null) {
displayable.display = this;
Expand Down
32 changes: 0 additions & 32 deletions js/me/javax/microedition/lcdui/Displayable.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,15 @@ js2me.createClass({
this.choiceButton = document.getElementById('choice');
this.backButton = document.getElementById('back');
this.commands = [];
this.commandListener = null;
this.choiceCommands = [];
this.backCommands = [];
var displayable = this;
displayable.currentCommands = [];
var moreMenuListener = {
/*
*
*/
$commandAction$Ljavax_microedition_lcdui_Command_Ljavax_microedition_lcdui_Displayable_$V: function () {
var command = displayable.currentCommands[displayable.moreList.$getSelectedIndex$$I()];
displayable.display.$setCurrent$Ljavax_microedition_lcdui_Displayable_$V(displayable);
displayable.commandListener.$commandAction$Ljavax_microedition_lcdui_Command_Ljavax_microedition_lcdui_Displayable_$V(command, displayable);
}
};
if (this.moreList == null) {
javaRoot.$javax.$microedition.$lcdui.$Displayable.prototype.moreList = {};
var list = new javaRoot.$javax.$microedition.$lcdui.$List();
javaRoot.$javax.$microedition.$lcdui.$Displayable.prototype.moreList = list;
}
this.choiceButton.addEventListener('mousedown', function () {
if (displayable.commandListener && displayable.active) {
displayable.currentCommands = displayable.choiceCommands;
if (displayable.choiceCommands.length == 1) {
displayable.commandListener.$commandAction$Ljavax_microedition_lcdui_Command_Ljavax_microedition_lcdui_Displayable_$V(displayable.choiceCommands[0], displayable);
}
if (displayable.choiceCommands.length > 1) {
displayable.display.$setCurrent$Ljavax_microedition_lcdui_Displayable_$V(displayable.moreList);
displayable.moreList.$setCommandListener$Ljavax_microedition_lcdui_CommandListener_$V(moreMenuListener);
displayable.moreList.$deleteAll$$V();
for (var i = 0; i < displayable.currentCommands.length; i++) {
displayable.moreList.$append$Ljava_lang_String_Ljavax_microedition_lcdui_Image_$I(displayable.currentCommands[i].label, null);
}
}
}
});
this.backButton.addEventListener('mousedown', function () {
if (displayable.backCommands.length == 1 && displayable.commandListener) {
displayable.commandListener.$commandAction$Ljavax_microedition_lcdui_Command_Ljavax_microedition_lcdui_Displayable_$V(displayable.backCommands[0], displayable);
}
});
},
/*
* public void setTitle(String s)
Expand Down
1 change: 1 addition & 0 deletions js/me/javax/microedition/lcdui/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ js2me.createClass({
$append$Ljavax_microedition_lcdui_Image_$I: function (image) {
var item = new javaRoot.$javax.$microedition.$lcdui.$ImageItem();
item._init$Ljava_lang_String_Ljavax_microedition_lcdui_Image_ILjava_lang_String_$V(null, image, 0, null);
this.$append$Ljavax_microedition_lcdui_Item_$I(item);
},
/*
* public int size()
Expand Down
2 changes: 1 addition & 1 deletion manifest.webapp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.8",
"version": "1.0",
"name": "JayME",
"description": "Java Mobile Edition emulator for Firefox OS.",
"type": "privileged",
Expand Down
21 changes: 0 additions & 21 deletions tests/form/Test.java

This file was deleted.

Binary file removed tests/form/test.png
Binary file not shown.

0 comments on commit 8184d30

Please sign in to comment.