RuneOptimizer.py 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #!/usr/bin/env python
  2. """
  3. This file is part of RuneOptimizer.
  4. RuneOptimizer is free software: you can redistribute it and/or modify it
  5. under the terms of the GNU General Public License as published by the Free
  6. Software Foundation, either version 3 of the License, or (at your option)
  7. any later version.
  8. RuneOptimizer is distributed in the hope that it will be useful, but WITHOUT
  9. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. more details.
  12. You should have received a copy of the GNU General Public License along with
  13. RuneOptimizer. If not, see <https://www.gnu.org/licenses/>.
  14. """
  15. import wx
  16. import wx.grid
  17. import wx.adv
  18. import sqlite3
  19. import math
  20. import subprocess
  21. from subprocess import Popen, PIPE
  22. import json
  23. import os
  24. import pipes
  25. from types import SimpleNamespace
  26. from time import sleep
  27. # Include files
  28. classesToInclude = [
  29. '/classes/PanelUnits.py',
  30. '/classes/PanelTeams.py',
  31. '/classes/PanelOptimizer.py',
  32. '/classes/PanelResults.py',
  33. '/classes/PanelInfo.py',
  34. '/classes/RuneOptimizerFrame.py',
  35. '/classes/TabList.py',
  36. '/classes/DialogConfirm.py',
  37. '/classes/DialogUpdateJson.py',
  38. '/classes/DialogNewTeam.py',
  39. ]
  40. for cls in classesToInclude:
  41. exec(
  42. compile(
  43. source=open(os.path.dirname(os.path.realpath(__file__)) + cls).read(),
  44. filename=os.path.dirname(os.path.realpath(__file__)) + cls,
  45. mode='exec'
  46. )
  47. )
  48. # The path to the RuneOptimizer executable. Different in Windows.
  49. executable_path = \
  50. os.path.dirname(os.path.realpath(__file__)) + '/../../RuneOptimizer'
  51. if os.name == 'nt':
  52. executable_path = \
  53. os.path.dirname(os.path.realpath(__file__)) + '\..\..\RuneOptimizer.exe'
  54. # App information
  55. app_info = {
  56. "name": "Rune Optimizer",
  57. "app_version": "UNKNOWN",
  58. "gui_version": "0.1-RC1",
  59. "author": "Iñigo Valentin",
  60. "author_mail": "i@inigovalentin.com",
  61. "url": {
  62. "Home page": "https://inigovalentin.com/projects/RuneOptimizer/",
  63. "Source code": "https://github.com/InigoValentin/RuneOptimizer/"
  64. }
  65. }
  66. # Global database connection
  67. conn = None
  68. # Unit stat names, indexed with Com2Us values.
  69. stat_names = [
  70. "NULL", "HP ", "HP% ", "ATK ", "ATK%", "DEF ",
  71. "DEF%", "NULL", "SPD ", "CRR ", "CRD ", "RES ", "ACC "
  72. ]
  73. # Rune set names, indexed with Com2Us values.
  74. set_names = [
  75. "NULL", "ENERGY", "GUARD", "SWIFT", "BLADE", "RAGE",
  76. "FOCUS", "ENDURE", "FATAL", "NULL", "DESPAIR", "VAMPIRE",
  77. "NULL", "VIOLENT", "NEMESIS", "WILL", "SHIELD", "REVENGE",
  78. "DESTROY", "FIGHT", "DETERMINATION", "ENHANCE", "ACCURACY", "TOLERANCE"
  79. ]
  80. if __name__ == '__main__':
  81. """
  82. Main function.
  83. Conects to the database and shows the initial frame.
  84. """
  85. #Get CLI app version
  86. print("EXEC PATH: " + executable_path)
  87. app_info["app_version"] = subprocess.check_output(
  88. [
  89. executable_path,
  90. 'version'
  91. ]
  92. )
  93. # Open the database
  94. conn = sqlite3.connect(
  95. os.path.dirname(os.path.realpath(__file__)) + '/../../data.sqlite'
  96. )
  97. # Start the GUI
  98. app = wx.App()
  99. frm = RuneOptimizerFrame(
  100. parent=None, title='Rune Optimizer', pos=(100, 100), size=(800, 600)
  101. )
  102. frm.Show()
  103. app.MainLoop()