13
13
14
14
#include < fstream>
15
15
#include < iostream>
16
+ #include < lua_system.hpp>
16
17
17
18
18
19
/*
@@ -486,7 +487,7 @@ void LuaFile::load()
486
487
" getTextWidth" , &LuaLabel::getTextWidth,
487
488
" setVerticalAlignment" , &LuaLabel::setVerticalAlignment,
488
489
" setHorizontalAlignment" , &LuaLabel::setHorizontalAlignment,
489
- " setTextColor" , &LuaLabel::setTextColor,
490
+ " setTextColor" , sol::overload ( &LuaLabel::setTextColor, &LuaLabel::setTextColorRGB) ,
490
491
sol::base_classes, sol::bases<LuaWidget>());
491
492
492
493
lua.new_usertype <LuaInput>(" LuaInput" ,
@@ -648,6 +649,43 @@ void LuaFile::load()
648
649
lua[" gsm" ] = luaGSM;
649
650
}
650
651
652
+ /*
653
+ * System.
654
+ *
655
+ * @todo Add permission.
656
+ */
657
+ {
658
+ // TODO: Move this from this scope to the "global lua" scope.
659
+ auto paxo = lua[" paxo" ].get_or_create <sol::table>(sol::new_table ());
660
+
661
+ auto system = paxo[" system" ].get_or_create <sol::table>(sol::new_table ());
662
+ auto systemConfig = system [" config" ].get_or_create <sol::table>(sol::new_table ());
663
+
664
+ // paxo.system.config.get()
665
+ systemConfig.set_function (" get" , sol::overload (
666
+ &paxolua::system ::config::getBool,
667
+ // &paxolua::system::config::getInt,
668
+ &paxolua::system ::config::getFloat,
669
+ &paxolua::system ::config::getString
670
+ ));
671
+
672
+ // paxo.system.config.set()
673
+ systemConfig.set_function (" set" , sol::overload (
674
+ &paxolua::system ::config::setBool,
675
+ // &paxolua::system::config::setInt,
676
+ &paxolua::system ::config::setFloat,
677
+ &paxolua::system ::config::setString
678
+ ));
679
+
680
+ systemConfig.set_function (" write" , &paxolua::system ::config::write );
681
+
682
+ auto app = paxo[" app" ].get_or_create <sol::table>(sol::new_table ());
683
+
684
+ app.set_function (" quit" , [&]() {
685
+ m_commandQueue.push (QUIT);
686
+ });
687
+ }
688
+
651
689
{ // load events
652
690
sol::table luaEvents = lua.create_table ();
653
691
@@ -729,8 +767,19 @@ void LuaFile::stop(std::vector<std::string> arg)
729
767
lua[" quit" ](arg);
730
768
}
731
769
732
- void LuaFile::loop ()
733
- {
770
+ void LuaFile::loop () {
771
+ // Process commands
772
+ while (!m_commandQueue.empty ()) {
773
+ switch (m_commandQueue.front ()) {
774
+ case QUIT:
775
+ // Quit lua app OUTSIDE of lua
776
+ AppManager::quitApp ();
777
+ break ;
778
+ }
779
+
780
+ m_commandQueue.pop ();
781
+ }
782
+
734
783
// lua_gui.update(); // add App Priority To Acces Gui
735
784
lua_time.update ();
736
785
}
0 commit comments