mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
2
Makefile
2
Makefile
@@ -178,7 +178,7 @@ cleanandcompile:
|
||||
.PHONY: start
|
||||
start:
|
||||
@echo "INFO Starting output/$(BUILD_TYPE)/simulator/$(HOST)/epsilon.$(EXE)"
|
||||
@$(Q) output/$(BUILD_TYPE)/simulator/$(HOST)/epsilon.$(EXE)
|
||||
@$(Q) output/$(BUILD_TYPE)/simulator/$(HOST)/epsilon.$(EXE) -v
|
||||
|
||||
.PHONY: clean_run
|
||||
clean_run: cleanandcompile
|
||||
|
||||
@@ -25,6 +25,7 @@ const Image * App::Descriptor::icon() {
|
||||
App::Snapshot::Snapshot() :
|
||||
#if EPSILON_GETOPT
|
||||
m_lockOnConsole(false),
|
||||
m_hasBeenWiped(false),
|
||||
#endif
|
||||
m_scriptStore()
|
||||
{
|
||||
@@ -49,10 +50,12 @@ bool App::Snapshot::lockOnConsole() const {
|
||||
}
|
||||
|
||||
void App::Snapshot::setOpt(const char * name, const char * value) {
|
||||
if (strcmp(name, "wipe") == 0) {
|
||||
m_scriptStore.deleteAllScripts();
|
||||
}
|
||||
if (strcmp(name, "script") == 0) {
|
||||
if (!m_hasBeenWiped) {
|
||||
m_hasBeenWiped = true;
|
||||
m_scriptStore.deleteAllScripts();
|
||||
}
|
||||
|
||||
char * separator = const_cast<char *>(UTF8Helper::CodePointSearch(value, ':'));
|
||||
if (*separator == 0) {
|
||||
return;
|
||||
|
||||
@@ -34,6 +34,7 @@ public:
|
||||
private:
|
||||
#if EPSILON_GETOPT
|
||||
bool m_lockOnConsole;
|
||||
bool m_hasBeenWiped;
|
||||
#endif
|
||||
ScriptStore m_scriptStore;
|
||||
};
|
||||
|
||||
@@ -69,6 +69,11 @@ PythonImportKandinsky = "kandinsky Modul importieren"
|
||||
PythonImportRandom = "random Modul importieren"
|
||||
PythonImportMath = "math Modul importieren"
|
||||
PythonImportMatplotlibPyplot = "Import matplotlib.pyplot module"
|
||||
PythonImportOs = "os Modul importieren"
|
||||
PythonOsUname = "Informieren Sie sich über das System"
|
||||
PythonOsRemove = "Datei namens Dateiname entfernen"
|
||||
PythonOsRename = "Datei mit altem Namen in neuen Namen umbenennen"
|
||||
PythonOsListdir = "Dateien im Speicher auflisten"
|
||||
PythonImportTime = "time Modul importieren"
|
||||
PythonImportTurtle = "turtle Modul importieren"
|
||||
PythonIndex = "Index, bei dem x zuerst vorkommt"
|
||||
|
||||
@@ -196,6 +196,11 @@ PythonTurtleSpeed = "Drawing speed between 0 and 10"
|
||||
PythonTurtleWrite = "Display a text"
|
||||
PythonUniform = "Floating point number in [a,b]"
|
||||
PythonImportTime = "Import time module"
|
||||
PythonImportOs = "Import os module"
|
||||
PythonOsUname = "Get infos about the system"
|
||||
PythonOsRemove = "Remove file named filename"
|
||||
PythonOsRename = "Rename file oldname to newname"
|
||||
PythonOsListdir = "List files in memory"
|
||||
PythonTimePrefix = "time module function prefix"
|
||||
PythonTimeSleep = "Wait for n second"
|
||||
PythonMonotonic = "Return monotonic time"
|
||||
|
||||
@@ -196,6 +196,11 @@ PythonTurtleSpeed = "Drawing speed between 0 and 10"
|
||||
PythonTurtleWrite = "Display a text"
|
||||
PythonUniform = "Floating point number in [a,b]"
|
||||
PythonImportTime = "Import time module"
|
||||
PythonImportOs = "Import os module"
|
||||
PythonOsUname = " Información del sistema "
|
||||
PythonOsRemove = "Eliminar un archivo"
|
||||
PythonOsRename = "Renombrar archivo"
|
||||
PythonOsListdir = "Archivos de la lista"
|
||||
PythonTimePrefix = "time module function prefix"
|
||||
PythonTimeSleep = "Esperar n segundos"
|
||||
PythonMonotonic = "Tiempo monótono de retorno"
|
||||
|
||||
@@ -196,6 +196,11 @@ PythonTurtleSpeed = "Vitesse du tracé entre 0 et 10"
|
||||
PythonTurtleWrite = "Affiche un texte"
|
||||
PythonUniform = "Nombre décimal dans [a,b]"
|
||||
PythonImportTime = "Importation du module temps"
|
||||
PythonImportOs = "Importation du module os"
|
||||
PythonOsUname = "Donne des infos sur le système"
|
||||
PythonOsRemove = "Supprime le fichier nommé filename"
|
||||
PythonOsRename = "Renomme oldname en newname"
|
||||
PythonOsListdir = "Liste les fichiers"
|
||||
PythonTimePrefix = "Préfixe fonction du module temps"
|
||||
PythonTimeSleep = "Attendre n secondes"
|
||||
PythonMonotonic = "Retourne le temps monotonic"
|
||||
|
||||
@@ -70,6 +70,11 @@ PythonImportRandom = "Véletlenszerü modul importálása"
|
||||
PythonImportMath = "Import matematikai modul"
|
||||
PythonImportMatplotlibPyplot = "Import matplotlib.pyplot module"
|
||||
PythonImportTime = "Idömodul importálása"
|
||||
PythonImportOs = "Os modul importálása"
|
||||
PythonOsUname = "Információ a rendszerről"
|
||||
PythonOsRemove = "Fájl eltávolítása"
|
||||
PythonOsRename = "Fájl átnevezése"
|
||||
PythonOsListdir = "Fájlok listázása"
|
||||
PythonImportTurtle = "Import teknös modul"
|
||||
PythonIndex = "Az elsö x esemény indexe"
|
||||
PythonInput = "Érték kérése"
|
||||
|
||||
@@ -71,6 +71,11 @@ PythonImportMath = "Importa modulo math"
|
||||
PythonImportMatplotlibPyplot = "Importa modulo matplotlib.pyplot"
|
||||
PythonImportTurtle = "Importa del modulo turtle"
|
||||
PythonImportTime = "Importa del modulo time"
|
||||
PythonImportOs = "Importa modulo os"
|
||||
PythonOsUname = "Ottieni informazioni sul sistema"
|
||||
PythonOsRemove = "Rimuovere un file"
|
||||
PythonOsRename = "Rinomina file"
|
||||
PythonOsListdir = "Elenca file"
|
||||
PythonIndex = "Indice prima occorrenza di x"
|
||||
PythonInput = "Inserire un valore"
|
||||
PythonInsert = "Inserire x in posizione i-esima"
|
||||
|
||||
@@ -70,6 +70,11 @@ PythonImportRandom = "Importeer random module"
|
||||
PythonImportMath = "Importeer math module"
|
||||
PythonImportMatplotlibPyplot = "Import matplotlib.pyplot module"
|
||||
PythonImportTime = "Importeer time module"
|
||||
PythonImportOs = "Importeer os module"
|
||||
PythonOsUname = " Krijg systeeminfo"
|
||||
PythonOsRemove = "Een bestand verwijderen"
|
||||
PythonOsRename = "Hernoem bestand"
|
||||
PythonOsListdir = "Lijstbestanden"
|
||||
PythonImportTurtle = "Importeer turtle module"
|
||||
PythonIndex = "Index van de eerste x aanwezigheden"
|
||||
PythonInput = "Wijs een waarde toe"
|
||||
|
||||
@@ -196,6 +196,11 @@ PythonTurtleSpeed = "Velocidade do desenho entre 0 e 10"
|
||||
PythonTurtleWrite = "Mostrar um texto"
|
||||
PythonUniform = "Número decimal em [a,b]"
|
||||
PythonImportTime = "Import time module"
|
||||
PythonImportOs = "Import os module"
|
||||
PythonOsUname = " Obter informações do sistema"
|
||||
PythonOsRemove = "Remover um ficheiro"
|
||||
PythonOsRename = "Renomear ficheiro"
|
||||
PythonOsListdir = "Listar ficheiros"
|
||||
PythonTimePrefix = "time module function prefix"
|
||||
PythonTimeSleep = "Wait for n second"
|
||||
PythonMonotonic = "Return monotonic time"
|
||||
|
||||
@@ -86,6 +86,8 @@ PythonCommandImportKandinsky = "import kandinsky"
|
||||
PythonCommandImportMath = "import math"
|
||||
PythonCommandImportMatplotlibPyplot = "import matplotlib.pyplot"
|
||||
PythonCommandImportRandom = "import random"
|
||||
PythonCommandImportOs = "import os"
|
||||
PythonCommandImportFromOs = "from os import *"
|
||||
PythonCommandImportTime = "import time"
|
||||
PythonCommandImportTurtle = "import turtle"
|
||||
PythonCommandIndex = "list.index(x)"
|
||||
@@ -212,6 +214,12 @@ PythonCommandTurtleFunctionWithoutArg = "turtle.\x11"
|
||||
PythonCommandUniform = "uniform(a,b)"
|
||||
PythonConstantE = "2.718281828459045"
|
||||
PythonConstantPi = "3.141592653589793"
|
||||
PythonOsCommandUname = "uname()"
|
||||
PythonOsCommandRemove = "remove(filename)"
|
||||
PythonOsCommandRename = "rename(oldname, newname)"
|
||||
PythonOsCommandRemoveWithoutArg = "remove(\x11)"
|
||||
PythonOsCommandRenameWithoutArg = "rename(\x11,)"
|
||||
PythonOsCommandListdir = "listdir()"
|
||||
PythonTurtleCommandBackward = "backward(x)"
|
||||
PythonTurtleCommandCircle = "circle(r)"
|
||||
PythonTurtleCommandColor = "color('c')"
|
||||
|
||||
@@ -256,6 +256,15 @@ const ToolboxMessageTree TimeModuleChildren[] = {
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandSleep, I18n::Message::PythonSleep)
|
||||
};
|
||||
|
||||
const ToolboxMessageTree OsModuleChildren[] = {
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandImportOs, I18n::Message::PythonImportOs, false),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonCommandImportFromOs, I18n::Message::PythonImportOs, false),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonOsCommandUname, I18n::Message::PythonOsUname, false),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonOsCommandRemove, I18n::Message::PythonOsRemove, false, I18n::Message::PythonOsCommandRemoveWithoutArg),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonOsCommandRename, I18n::Message::PythonOsRename, false, I18n::Message::PythonOsCommandRenameWithoutArg),
|
||||
ToolboxMessageTree::Leaf(I18n::Message::PythonOsCommandListdir, I18n::Message::PythonOsListdir, false)
|
||||
};
|
||||
|
||||
const ToolboxMessageTree modulesChildren[] = {
|
||||
ToolboxMessageTree::Node(I18n::Message::MathModule, MathModuleChildren),
|
||||
ToolboxMessageTree::Node(I18n::Message::CmathModule, CMathModuleChildren),
|
||||
@@ -264,6 +273,7 @@ const ToolboxMessageTree modulesChildren[] = {
|
||||
ToolboxMessageTree::Node(I18n::Message::RandomModule, RandomModuleChildren),
|
||||
ToolboxMessageTree::Node(I18n::Message::KandinskyModule, KandinskyModuleChildren),
|
||||
ToolboxMessageTree::Node(I18n::Message::IonModule, IonModuleChildren),
|
||||
ToolboxMessageTree::Node(I18n::Message::OsModule, OsModuleChildren),
|
||||
ToolboxMessageTree::Node(I18n::Message::TimeModule, TimeModuleChildren)
|
||||
};
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ IonModule = "ion"
|
||||
KandinskyModule = "kandinsky"
|
||||
MathModule = "math"
|
||||
MatplotlibPyplotModule = "matplotlib.pyplot"
|
||||
OsModule = "os"
|
||||
TimeModule = "time"
|
||||
TurtleModule = "turtle"
|
||||
ForLoopMenu = "For"
|
||||
|
||||
@@ -24,11 +24,11 @@ ifndef ARCH
|
||||
|
||||
$(BUILD_DIR)/app/res/mipmap/ic_launcher.png: ion/src/simulator/assets/logo.svg | $$(@D)/.
|
||||
$(call rule_label,CONVERT)
|
||||
$(Q) convert -background "#FFB734" $< $@
|
||||
$(Q) convert -background "#b1403b" $< $@
|
||||
|
||||
$(BUILD_DIR)/app/res/mipmap-v26/ic_launcher_foreground.png: ion/src/simulator/assets/logo.svg | $$(@D)/.
|
||||
$(call rule_label,CONVERT)
|
||||
$(Q) convert -background none $< -resize 512x512 -gravity center -background none -extent 1024x1024 $@
|
||||
$(Q) convert -background none $< -resize 1024x1024 -gravity center -background none -extent 1024x1024 $@
|
||||
|
||||
$(BUILD_DIR)/app/res/%.xml: ion/src/simulator/android/src/res/%.xml | $$(@D)/.
|
||||
$(call rule_label,COPY)
|
||||
@@ -58,7 +58,7 @@ apk_deps += $(addprefix $(BUILD_DIR)/app/res/,mipmap/ic_launcher.png mipmap-v26/
|
||||
|
||||
$(BUILD_DIR)/%.apk: $(apk_deps)
|
||||
$(call rule_label,GRADLE)
|
||||
$(Q) ANDROID_HOME=$(ANDROID_HOME) EPSILON_VERSION=$(EPSILON_VERSION) BUILD_DIR=$(BUILD_DIR) EPSILON_VARIANT=$* ion/src/simulator/android/gradlew -b ion/src/simulator/android/build.gradle assembleRelease
|
||||
$(Q) ANDROID_HOME=$(ANDROID_HOME) EPSILON_VERSION=$(EPSILON_VERSION) OMEGA_VERSION=$(OMEGA_VERSION) BUILD_DIR=$(BUILD_DIR) EPSILON_VARIANT=$* ion/src/simulator/android/gradlew -b ion/src/simulator/android/build.gradle assembleRelease
|
||||
$(Q) cp $(BUILD_DIR)/app/outputs/apk/release/android-release*.apk $@
|
||||
|
||||
endif
|
||||
|
||||
@@ -37,9 +37,9 @@ android {
|
||||
applicationId "io.github.omega.simulator"
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 28
|
||||
def (major, minor, patch) = System.getenv('EPSILON_VERSION').toLowerCase().tokenize('.').collect{it.toInteger()}
|
||||
def (major, minor, patch) = System.getenv('OMEGA_VERSION').toLowerCase().tokenize('.').collect{it.toInteger()}
|
||||
versionCode major*1000000 + minor*10000 + patch * 100
|
||||
versionName System.getenv('EPSILON_VERSION')
|
||||
versionName System.getenv('OMEGA_VERSION')
|
||||
}
|
||||
signingConfigs {
|
||||
environment {
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
package com.numworks.calculator;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.android.gms.analytics.GoogleAnalytics;
|
||||
import com.google.android.gms.analytics.Tracker;
|
||||
import com.google.android.gms.analytics.HitBuilders;
|
||||
|
||||
import org.libsdl.app.SDLActivity;
|
||||
|
||||
public class EpsilonActivity extends SDLActivity {
|
||||
private static GoogleAnalytics sAnalytics;
|
||||
private static Tracker sTracker;
|
||||
|
||||
protected String[] getLibraries() {
|
||||
return new String[] {
|
||||
"epsilon"
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] getArguments() {
|
||||
Locale currentLocale = getResources().getConfiguration().locale;
|
||||
String[] arguments = {"--language", currentLocale.getLanguage()};
|
||||
return arguments;
|
||||
}
|
||||
|
||||
public Bitmap retrieveBitmapAsset(String identifier) {
|
||||
Bitmap bitmap = null;
|
||||
try {
|
||||
bitmap = BitmapFactory.decodeStream(
|
||||
this.getResources().getAssets().open(identifier)
|
||||
);
|
||||
} catch (Exception e) {
|
||||
Log.w("LoadTexture", "Coundn't load a file:" + identifier);
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
public void telemetryInit() {
|
||||
sAnalytics = GoogleAnalytics.getInstance(this);
|
||||
sTracker = sAnalytics.newTracker("UA-93775823-3");
|
||||
}
|
||||
|
||||
public void telemetryScreen(String screenName) {
|
||||
sTracker.setScreenName(screenName);
|
||||
sTracker.send(new HitBuilders.ScreenViewBuilder().build());
|
||||
}
|
||||
|
||||
public void telemetryEvent(String category, String action, String label) {
|
||||
sTracker.send(new HitBuilders.EventBuilder()
|
||||
.setCategory(category)
|
||||
.setAction(action)
|
||||
.setLabel(label)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
/* This is done to hide the status bar and the bottom navigation buttons.
|
||||
*
|
||||
* In SDLActivity::onCreate, setWindowStyle(false) is called, which means
|
||||
* the fullscreen mode is put to false. We call again the method here with
|
||||
* true, in order not to modify the external sources.
|
||||
*
|
||||
* TODO: This was not needed for v12 of Epsilon, even though
|
||||
* setWindowStyle(false) was already called in SDLActivity::onCreate. Find
|
||||
* out why and make a proper fix? */
|
||||
super.onCreate(savedInstanceState);
|
||||
if (!mBrokenLibraries) {
|
||||
/* If mBrokenLibraries, SDL is not initialized by onCreate in
|
||||
* SDLActivity.java. */
|
||||
setWindowStyle(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -40,9 +40,21 @@ public class OmegaActivity extends SDLActivity {
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
/* This is done to hide the status bar and the bottom navigation buttons.
|
||||
*
|
||||
* In SDLActivity::onCreate, setWindowStyle(false) is called, which means
|
||||
* the fullscreen mode is put to false. We call again the method here with
|
||||
* true, in order not to modify the external sources.
|
||||
*
|
||||
* TODO: This was not needed for v12 of Epsilon, even though
|
||||
* setWindowStyle(false) was already called in SDLActivity::onCreate. Find
|
||||
* out why and make a proper fix? */
|
||||
super.onCreate(savedInstanceState);
|
||||
if (!mBrokenLibraries) {
|
||||
/* If mBrokenLibraries, SDL is not initialized by onCreate in
|
||||
* SDLActivity.java. */
|
||||
setWindowStyle(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 1024 1024"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
height="2048"
|
||||
width="2048"
|
||||
viewBox="0 0 2048 2048"
|
||||
version="1.1"
|
||||
id="svg4">
|
||||
id="svg4"
|
||||
sodipodi:docname="logo.svg"
|
||||
inkscape:version="1.0 (4035a4fb49, 2020-05-01)">
|
||||
<metadata
|
||||
id="metadata10">
|
||||
<rdf:RDF>
|
||||
@@ -28,9 +36,25 @@
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
id="namedview6"
|
||||
showgrid="false"/>
|
||||
showgrid="false"
|
||||
inkscape:document-rotation="0"
|
||||
inkscape:zoom="0.10241699"
|
||||
inkscape:cx="-688.3434"
|
||||
inkscape:cy="1290.1447"
|
||||
inkscape:window-width="1310"
|
||||
inkscape:window-height="740"
|
||||
inkscape:window-x="1970"
|
||||
inkscape:window-y="312"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg4" />
|
||||
<path
|
||||
d="M 786.42601,739.31189 H 662.42149 v -27.04386 c 36.3552,-22.06089 67.35755,-51.89166 90.72406,-87.52113 C 783.0817,579.10128 798.9071,526.1403 798.9071,471.5909 798.9071,315.76998 670.20061,189 512,189 353.79939,189 225.09533,315.76998 225.09533,471.59329 c 0,54.5494 15.82541,107.50799 45.76398,153.156 23.36652,35.62947 54.37129,65.45785 90.72406,87.51874 v 27.04386 H 237.57399 C 210.74657,739.31189 189,760.73167 189,787.15594 189,813.58022 210.74657,835 237.57399,835 h 172.58337 c 26.8274,0 48.57398,-21.41978 48.57398,-47.84406 V 683.87498 c 0,-18.49651 -10.82228,-35.33284 -27.79403,-43.24385 C 364.90826,609.84826 322.2433,543.49812 322.2433,471.59329 c 0,-103.05849 85.12348,-186.9052 189.7567,-186.9052 104.63322,0 189.75913,83.84671 189.75913,186.9052 0,71.90244 -42.66496,138.25497 -108.69401,169.03784 -16.96932,7.9134 -27.79161,24.74973 -27.79161,43.24385 V 787.15594 C 565.27351,813.58022 587.02009,835 613.8475,835 H 786.42601 C 813.25343,835 835,813.58022 835,787.15594 c 0,-26.42427 -21.74657,-47.84405 -48.57399,-47.84405 z"
|
||||
sodipodi:nodetypes="cssscccssscc"
|
||||
style="fill:#8c302c;stroke-width:2.41038;fill-opacity:1"
|
||||
id="path2-3-3"
|
||||
d="M 2086.4474,1595.3277 1226.7788,783.8626 c -64.0824,-60.4892 -89.833,-34.55421 -168.9333,-34.55421 -158.20066,0 -212.52746,-43.98944 -212.52746,111.83386 0,54.5494 -66.60562,125.57083 -36.66705,171.21885 23.36652,35.6295 55.19723,135.5702 91.55,157.6311 l -5.28265,104.6642 -136.8456,-15.7295 c -26.65194,-3.0635 -57.07276,-6.1952 -57.07276,20.229 0,13.2122 5.50243,25.1069 14.22671,33.8312 663.40551,663.4055 110.02167,109.7988 740.12111,739.8983 764.7091,175.1285 815.297,-196.8835 631.0996,-477.5577 z" />
|
||||
<path
|
||||
d="m 1298.4261,1251.3119 h -124.0045 v -27.0439 c 36.3552,-22.0609 67.3575,-51.8916 90.724,-87.5211 29.9362,-45.6456 45.7616,-98.6066 45.7616,-153.156 0,-77.91046 -32.1766,-148.55819 -84.1283,-199.7283 C 1174.8272,732.69249 1103.1004,701 1024.0001,701 865.79945,701 737.09539,827.76998 737.09539,983.59329 c 0,54.54941 15.82541,107.50801 45.76398,153.15601 23.36652,35.6295 54.37129,65.4578 90.72406,87.5187 v 27.0439 H 749.57405 c -26.82742,0 -48.57399,21.4198 -48.57399,47.844 0,13.2122 5.43664,25.1732 14.22671,33.8312 8.79007,8.658 20.93357,14.0129 34.34728,14.0129 h 172.58337 c 26.8274,0 48.57398,-21.4198 48.57398,-47.8441 V 1195.875 c 0,-18.4965 -10.82228,-35.3329 -27.79403,-43.2439 -66.02905,-30.7828 -108.69401,-97.133 -108.69401,-169.03781 0,-103.05849 85.12348,-186.9052 189.75674,-186.9052 104.6332,0 189.7591,83.84671 189.7591,186.9052 0,71.90241 -42.6649,138.25501 -108.694,169.03781 -16.9693,7.9134 -27.7916,24.7498 -27.7916,43.2439 v 103.2809 c 0,26.4243 21.7466,47.8441 48.574,47.8441 h 172.5785 c 26.8274,0 48.574,-21.4198 48.574,-47.8441 0,-26.4242 -21.7466,-47.844 -48.574,-47.844 z"
|
||||
id="path2-3"
|
||||
style="fill:#ffffff;stroke-width:2.41038179" />
|
||||
style="fill:#ffffff;stroke-width:2.41038"
|
||||
sodipodi:nodetypes="scccsssscccssssssscssscssssss" />
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 3.3 KiB |
@@ -10,12 +10,20 @@
|
||||
#include <stdio.h>
|
||||
#include <ion/timing.h>
|
||||
#include <ion/events.h>
|
||||
#include <ion/storage.h>
|
||||
#include <SDL.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
static bool argument_screen_only = false;
|
||||
static bool argument_fullscreen = false;
|
||||
static bool argument_unresizable = false;
|
||||
static bool argument_volatile = false;
|
||||
static char* pref_path = nullptr;
|
||||
static char* file_buffer = nullptr;
|
||||
|
||||
static void loadPython(std::vector<const char *>* arguments);
|
||||
static void savePython();
|
||||
|
||||
void Ion::Timing::msleep(uint32_t ms) {
|
||||
SDL_Delay(ms);
|
||||
@@ -26,10 +34,21 @@ void print_help(char * program_name) {
|
||||
printf("Options:\n");
|
||||
printf(" -f, --fullscreen Starts the emulator in fullscreen\n");
|
||||
printf(" -s, --screen-only Disable the keyboard.\n");
|
||||
printf(" -v, --volatile Disable saving and loading python scripts from file.\n");
|
||||
printf(" -u, --unresizable Disable resizing the window.\n");
|
||||
printf(" -h, --help Show this help menu.\n");
|
||||
}
|
||||
|
||||
int event_filter(void* userdata, SDL_Event* e) {
|
||||
if (e->type == SDL_APP_TERMINATING || e->type == SDL_APP_WILLENTERBACKGROUND) {
|
||||
savePython();
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
std::vector<const char *> arguments(argv, argv + argc);
|
||||
|
||||
@@ -43,6 +62,8 @@ int main(int argc, char * argv[]) {
|
||||
argument_fullscreen = true;
|
||||
} else if(strcmp(argv[i], "-u")==0 || strcmp(argv[i], "--unresizable")==0) {
|
||||
argument_unresizable = true;
|
||||
} else if(strcmp(argv[i], "-v")==0 || strcmp(argv[i], "--volatile")==0) {
|
||||
argument_volatile = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,13 +78,127 @@ int main(int argc, char * argv[]) {
|
||||
arguments.push_back(language);
|
||||
}
|
||||
|
||||
#ifndef __EMSCRIPTEN__
|
||||
if (!argument_volatile) {
|
||||
loadPython(&arguments);
|
||||
SDL_SetEventFilter(event_filter, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
Ion::Simulator::Main::init();
|
||||
|
||||
ion_main(arguments.size(), &arguments[0]);
|
||||
|
||||
#ifndef __EMSCRIPTEN__
|
||||
if (!argument_volatile) {
|
||||
savePython();
|
||||
}
|
||||
#endif
|
||||
|
||||
Ion::Simulator::Main::quit();
|
||||
|
||||
if (file_buffer != nullptr)
|
||||
SDL_free(file_buffer);
|
||||
if (pref_path != nullptr)
|
||||
SDL_free(pref_path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void loadPython(std::vector<const char *>* arguments) {
|
||||
pref_path = SDL_GetPrefPath("io.github.omega", "omega-simulator");
|
||||
std::string path(pref_path);
|
||||
printf("Loading from %s\n", (path + "python.dat").c_str());
|
||||
|
||||
SDL_RWops* save_file = SDL_RWFromFile((path + "python.dat").c_str(), "rb");
|
||||
|
||||
if (save_file != NULL) {
|
||||
// Calculate checksum
|
||||
uint64_t checksum = 0;
|
||||
uint64_t calc_checksum = 0;
|
||||
|
||||
SDL_RWread(save_file, &checksum, sizeof(uint64_t), 1);
|
||||
|
||||
uint8_t curr_check = 0;
|
||||
|
||||
while(SDL_RWread(save_file, &curr_check, sizeof(uint8_t), 1)) {
|
||||
calc_checksum += curr_check;
|
||||
}
|
||||
|
||||
if (checksum == calc_checksum) {
|
||||
arguments->push_back("--code-wipe");
|
||||
arguments->push_back("true");
|
||||
|
||||
uint64_t length = SDL_RWseek(save_file, 0, RW_SEEK_END) - sizeof(uint64_t);
|
||||
|
||||
SDL_RWseek(save_file, sizeof(uint64_t), RW_SEEK_SET);
|
||||
|
||||
file_buffer = (char*) SDL_malloc(length);
|
||||
SDL_RWread(save_file, file_buffer, length, 1);
|
||||
|
||||
// printf("Length: %ld\n", length);
|
||||
size_t i = 0;
|
||||
while(i < length) {
|
||||
uint16_t size = *(uint16_t*)(file_buffer + i);
|
||||
arguments->push_back("--code-script");
|
||||
arguments->push_back((char*)(file_buffer + i + sizeof(uint16_t)));
|
||||
// printf("Loaded size=%d i=%ld, %s\n", size, i+size, (char*)(file_buffer + i + sizeof(uint16_t)));
|
||||
i += size + sizeof(uint16_t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void savePython() {
|
||||
std::string path(pref_path);
|
||||
|
||||
printf("Saving to %s\n", (path + "python.dat").c_str());
|
||||
|
||||
SDL_RWops* save_file = SDL_RWFromFile((path + "python.dat").c_str(), "wb+");
|
||||
|
||||
if (save_file != NULL) {
|
||||
|
||||
// Placeholder for checksum
|
||||
uint64_t checksum = 0;
|
||||
SDL_RWwrite(save_file, &checksum, sizeof(uint64_t), 1);
|
||||
|
||||
uint16_t num = (uint16_t) Ion::Storage::sharedStorage()->numberOfRecordsWithExtension("py");
|
||||
|
||||
// Write all checksums
|
||||
for(uint16_t i = 0; i < num; i++) {
|
||||
Ion::Storage::Record record = Ion::Storage::sharedStorage()->recordWithExtensionAtIndex("py", i);
|
||||
|
||||
const char* record_name = record.fullName();
|
||||
uint16_t record_name_len = strlen(record_name);
|
||||
|
||||
Ion::Storage::Record::Data record_data = record.value();
|
||||
|
||||
uint16_t total_length = record_name_len + record_data.size;
|
||||
|
||||
SDL_RWwrite(save_file, &total_length, sizeof(uint16_t), 1);
|
||||
|
||||
SDL_RWwrite(save_file, record_name, record_name_len, 1);
|
||||
SDL_RWwrite(save_file, ":", 1, 1);
|
||||
// Remove import status, keep trailing \x00
|
||||
SDL_RWwrite(save_file, ((char*)record_data.buffer + 1), record_data.size - 1, 1);
|
||||
}
|
||||
|
||||
// Compute and write checksum
|
||||
|
||||
SDL_RWseek(save_file, sizeof(uint64_t), RW_SEEK_SET);
|
||||
uint8_t curr_check = 0;
|
||||
|
||||
while(SDL_RWread(save_file, &curr_check, sizeof(uint8_t), 1)) {
|
||||
checksum += curr_check;
|
||||
}
|
||||
|
||||
SDL_RWseek(save_file, 0, RW_SEEK_SET);
|
||||
SDL_RWwrite(save_file, &checksum, sizeof(uint64_t), 1);
|
||||
|
||||
SDL_RWclose(save_file);
|
||||
}
|
||||
}
|
||||
|
||||
namespace Ion {
|
||||
namespace Simulator {
|
||||
namespace Main {
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
extern "C" {
|
||||
#include <py/smallint.h>
|
||||
#include <py/objint.h>
|
||||
#include <py/objstr.h>
|
||||
#include <py/objtype.h>
|
||||
#include <py/runtime.h>
|
||||
#include <py/stream.h>
|
||||
#include <py/builtin.h>
|
||||
#include <py/obj.h>
|
||||
#include <py/misc.h>
|
||||
#include "uname_result.h"
|
||||
}
|
||||
|
||||
STATIC void uname_result_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind);
|
||||
STATIC mp_obj_t uname_result_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args);
|
||||
STATIC void uname_result_attr(mp_obj_t self_in, qstr attribute, mp_obj_t *destination);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user