RuneOptimizer.py 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. import appdirs
  26. from types import SimpleNamespace
  27. from time import sleep
  28. # Include files
  29. classesToInclude = [
  30. '/classes/PanelUnits.py',
  31. '/classes/PanelTeams.py',
  32. '/classes/PanelOptimizer.py',
  33. '/classes/PanelResults.py',
  34. '/classes/PanelInfo.py',
  35. '/classes/RuneOptimizerFrame.py',
  36. '/classes/TabList.py',
  37. '/classes/DialogConfirm.py',
  38. '/classes/DialogUpdateJson.py',
  39. '/classes/DialogNewTeam.py',
  40. ]
  41. for cls in classesToInclude:
  42. exec(
  43. compile(
  44. source=open(os.path.dirname(os.path.realpath(__file__)) + cls).read(),
  45. filename=os.path.dirname(os.path.realpath(__file__)) + cls,
  46. mode='exec'
  47. )
  48. )
  49. # The path to the RuneOptimizer executable. Different in Windows.
  50. executable_path = \
  51. os.path.dirname(os.path.realpath(__file__)) + '/../RuneOptimizer'
  52. if os.name == 'nt':
  53. executable_path = \
  54. os.path.dirname(os.path.realpath(__file__)) + '\..\RuneOptimizer.exe'
  55. # App information
  56. app_info = {
  57. "name": "Rune Optimizer",
  58. "app_version": "UNKNOWN",
  59. "gui_version": "0.1-RC1",
  60. "author": "Iñigo Valentin",
  61. "author_mail": "i@inigovalentin.com",
  62. "url": {
  63. "Home page": "https://inigovalentin.com/projects/RuneOptimizer/",
  64. "Source code": "https://github.com/InigoValentin/RuneOptimizer/"
  65. }
  66. }
  67. # Global database connection
  68. conn = None
  69. # Unit stat names, indexed with Com2Us values.
  70. stat_names = [
  71. "NULL", "HP ", "HP% ", "ATK ", "ATK%", "DEF ",
  72. "DEF%", "NULL", "SPD ", "CRR ", "CRD ", "RES ", "ACC "
  73. ]
  74. # Rune set names, indexed with Com2Us values.
  75. set_names = [
  76. "NULL", "ENERGY", "GUARD", "SWIFT", "BLADE", "RAGE", # 0- 5
  77. "FOCUS", "ENDURE", "FATAL", "NULL", "DESPAIR", "VAMPIRE", # 6-11
  78. "NULL", "VIOLENT", "NEMESIS", "WILL", "SHIELD", "REVENGE", # 12-17
  79. "DESTROY", "FIGHT", "DETERMIN", "ENHANCE", "ACCURACY", "TOLERANCE" # 18-23
  80. ]
  81. if __name__ == '__main__':
  82. """
  83. Main function.
  84. Conects to the database and shows the initial frame.
  85. """
  86. #Get CLI app version
  87. # TODO: Change executable name for windows
  88. #if os.name == 'nt':
  89. app_info["app_version"] = subprocess.check_output(
  90. ['RuneOptimizer', 'version']
  91. )
  92. # TODO: Test for executable to exist
  93. # TODO: Test for database to exist
  94. # Open the database
  95. conn = sqlite3.connect(
  96. appdirs.user_data_dir("RuneOptimizer") + "/data.sqlite"
  97. )
  98. # Start the GUI
  99. app = wx.App()
  100. frm = RuneOptimizerFrame(
  101. parent=None, title='Rune Optimizer', pos=(100, 100), size=(800, 600)
  102. )
  103. frm.Show()
  104. app.MainLoop()