reintegration complete
This commit is contained in:
113
modules/Archimedes-Modules/Calculator/Calculator.cpp
Normal file
113
modules/Archimedes-Modules/Calculator/Calculator.cpp
Normal file
@@ -0,0 +1,113 @@
|
||||
#include "Calculator.h"
|
||||
#include "modules/ImguiModule/ImguiModule.h"
|
||||
|
||||
|
||||
Calculator::Calculator(Archimedes::App* a, void* h) : Archimedes::Module(a, h) {
|
||||
|
||||
name = "Calculator";
|
||||
|
||||
ImguiModule* im = new ImguiModule(a, h);
|
||||
deps[*im] = im;
|
||||
}
|
||||
|
||||
Calculator::~Calculator() {
|
||||
|
||||
if(app) {
|
||||
ImguiModule* im; { im = (ImguiModule*) moduleInstances[ImguiModule()]; }
|
||||
im->releaseContext(ImGui::GetCurrentContext());
|
||||
}
|
||||
}
|
||||
|
||||
void Calculator::onLoad() {
|
||||
|
||||
ImguiModule* im; { im = (ImguiModule*) moduleInstances[ImguiModule()]; }
|
||||
|
||||
if(!im) {
|
||||
std::cout << "No ImguiModule for Calculator!\n";
|
||||
std::abort();
|
||||
}
|
||||
|
||||
ImGui::SetCurrentContext(im->aquireContext());
|
||||
|
||||
}
|
||||
|
||||
void Calculator::run() {
|
||||
|
||||
if(open) {
|
||||
basicCalculator();
|
||||
} else {
|
||||
app->emitEvent(new Archimedes::DoUnloadModuleEvent(name));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Calculator::basicCalculator() {
|
||||
|
||||
static bool b = true;
|
||||
|
||||
static std::string s;
|
||||
|
||||
if(b) {
|
||||
|
||||
ImGui::Begin("Basic Calculator", &open);
|
||||
|
||||
ImGui::InputText("equation", &s);
|
||||
|
||||
if(ImGui::Button("7")) {
|
||||
s += "7";
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if(ImGui::Button("8")) {
|
||||
s += "8";
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if(ImGui::Button("9")) {
|
||||
s += "9";
|
||||
}
|
||||
if(ImGui::Button("4")) {
|
||||
s += "4";
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if(ImGui::Button("5")) {
|
||||
s += "5";
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if(ImGui::Button("6")) {
|
||||
s += "6";
|
||||
}
|
||||
if(ImGui::Button("1")) {
|
||||
s += "1";
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if(ImGui::Button("2")) {
|
||||
s += "2";
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if(ImGui::Button("3")) {
|
||||
s += "3";
|
||||
}
|
||||
if(ImGui::Button("0")) {
|
||||
s += "1";
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if(ImGui::Button(".")) {
|
||||
s += "2";
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if(ImGui::Button("")) {
|
||||
if(s.back() == ' ') {
|
||||
s.pop_back();
|
||||
s.pop_back();
|
||||
s.pop_back();
|
||||
} else {
|
||||
s.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
}
|
||||
|
||||
void Calculator::graphingCalculator() {
|
||||
|
||||
}
|
||||
26
modules/Archimedes-Modules/Calculator/Calculator.h
Normal file
26
modules/Archimedes-Modules/Calculator/Calculator.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#include "Archimedes.h"
|
||||
|
||||
class Calculator : public Archimedes::Module {
|
||||
|
||||
public:
|
||||
Calculator(Archimedes::App*, void*);
|
||||
|
||||
Calculator() { name = "Calculator"; }
|
||||
|
||||
~Calculator();
|
||||
|
||||
void onLoad();
|
||||
|
||||
void run();
|
||||
private:
|
||||
bool open = true;
|
||||
|
||||
void basicCalculator();
|
||||
|
||||
void graphingCalculator();
|
||||
};
|
||||
|
||||
#ifdef CALCULATOR_DYNAMIC
|
||||
typedef Calculator mtype;
|
||||
#include "endModule.h"
|
||||
#endif
|
||||
Reference in New Issue
Block a user