Skip to content
This repository has been archived by the owner on Mar 3, 2024. It is now read-only.

Commit

Permalink
fixed implicit imports to explict
Browse files Browse the repository at this point in the history
fixed import loop in actionsDialog
  • Loading branch information
ericoporto committed Jun 6, 2016
1 parent 6f18c94 commit 7c93c84
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 94 deletions.
7 changes: 2 additions & 5 deletions src/fgmk/Charas.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5 import QtGui, QtCore, QtWidgets
import actionDialog
import TXWdgt
from flowlayout import FlowLayout as FlowLayout
import fifl
import TileCharaset
from fgmk import actionDialog, TXWdgt, fifl, TileCharaset
from fgmk.flowlayout import FlowLayout as FlowLayout

# moves will be step and face, for all possibilities TileCharaset.facing
# so a radio to select move or face and for buttons - one for each direction.
Expand Down
14 changes: 5 additions & 9 deletions src/fgmk/Editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5 import QtGui, QtCore, QtWidgets
import actionDialog
import TXWdgt
from flowlayout import FlowLayout as FlowLayout
import gwserver
import fifl
import TileCharaset
import Charas
from fgmk import actionDialog, TXWdgt, gwserver, fifl, TileCharaset, Charas, actionsWdgt, gameInit
from fgmk.flowlayout import FlowLayout as FlowLayout


abspath = os.path.abspath(__file__)
dname = os.path.dirname(abspath)
Expand Down Expand Up @@ -521,7 +517,7 @@ def updateEventsList(self):
def addAction(self):
global sSettings

self.myActionsWidget = TXWdgt.ActionsWidget(sSettings, self)
self.myActionsWidget = actionsWdgt.ActionsWidget(sSettings, self)
if self.myActionsWidget.exec_() == QtWidgets.QDialog.Accepted:
actionToAdd = self.myActionsWidget.getValue()

Expand Down Expand Up @@ -837,7 +833,7 @@ def __init__(self, parent=None, **kwargs):
self.FancyWindow()

def selectStartPosition(self):
result = TXWdgt.selectStartingPosition(self, sSettings)
result = gameInit.selectStartingPosition(self, sSettings)

doSave = False
if(result[1] != "this"):
Expand Down
74 changes: 1 addition & 73 deletions src/fgmk/TXWdgt.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
from PIL import Image
from PIL.ImageQt import ImageQt
import numpy as np
import tMat
import actionDialog
import TileXtra
import fifl
from fgmk import tMat, TileXtra, fifl

def getLevelPathFromInitFile(gamefolder,levelname):
initFile=openInitFile(gamefolder)
Expand All @@ -29,22 +26,6 @@ def saveInitFile(gamefolder, initFileJsonTree):
f.close()
return initFileJsonTree

def selectStartingPosition(parent, psSettings):
myTeleporDialog = actionDialog.teleport(psSettings["gamefolder"],parent, None, False, "select starting position")
if myTeleporDialog.exec_() == QtWidgets.QDialog.Accepted:
returnActDlg = str(myTeleporDialog.getValue())
position=returnActDlg.split(';')
initFileJsonTree = openInitFile(psSettings["gamefolder"])
initFileJsonTree["Player"]["initPosX"] = int(position[0])*32
initFileJsonTree["Player"]["initPosY"] = (int(position[1])-1)*32
if(str(position[2]) != "this"):
initFileJsonTree["World"]["initLevel"] = str(position[2])
else:
initFileJsonTree["World"]["initLevel"] = str(parent.myMap.levelName)
return [initFileJsonTree,str(position[2])]



class CommandCTTileType(QUndoCommand):
def __init__(self, child, senderTileWdgt, pMap, ptileset, layer, changeTypeTo, description):
super().__init__(description)
Expand Down Expand Up @@ -265,59 +246,6 @@ def validateIsOk(self):
def getValue(self):
return self.returnValue

class ActionsWidget(QDialog):
def __init__(self, psSettings, parent=None, ischaras=False, **kwargs):
super().__init__(parent, **kwargs)
self.psSettings=psSettings
self.ischaras = ischaras

self.VBox = QVBoxLayout(self)
self.VBox.setAlignment(Qt.AlignTop)

filepath = os.path.join(os.path.dirname(os.path.abspath(__file__)),"actions/actionsList.json")
f = open( filepath, "r" )
e = json.load(f)
f.close()

self.parent = parent
self.actionButton = []

for action in e["actionList"]:
self.actionButton.append(QPushButton(action, self))
self.VBox.addWidget(self.actionButton[-1])
self.actionButton[-1].clicked.connect(self.getAction)

self.setGeometry(300, 40, 350, 650)
self.setWindowTitle('Select Action to add...')

self.show()

def getAction(self):

buttonThatSent = self.sender()
self.returnValue = buttonThatSent.text()

if(self.returnValue == "END" or self.returnValue == "ELSE"):
self.returnValue = [str(self.returnValue),""]
self.accept()
else:
newDialogFromName = getattr(actionDialog, str(self.returnValue))
if(self.ischaras is False):
self.myActionsDialog = newDialogFromName(self.psSettings["gamefolder"],self)
else:
self.myActionsDialog = newDialogFromName(self.psSettings["gamefolder"],self,None,True)

if self.myActionsDialog.exec_() == QtWidgets.QDialog.Accepted:
returnActDlg = str(self.myActionsDialog.getValue())

#self.returnValue.append('|')
self.returnValue = [str(self.returnValue),str(returnActDlg)]
self.accept()

def getValue(self):
return self.returnValue


class MiniPaletteWidget(QWidget):
def __init__(self, pMyTileset, parent=None, **kwargs):
super().__init__(parent, **kwargs)
Expand Down
4 changes: 1 addition & 3 deletions src/fgmk/TileCharaset.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import os
import sys
import json
import TileXtra
import tMat
from PIL import Image
from PIL.ImageQt import ImageQt
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5 import QtGui, QtCore, QtWidgets
import fifl
from fgmk import fifl, TileXtra, tMat

### TODO fix enter on QLineEdit

Expand Down
2 changes: 1 addition & 1 deletion src/fgmk/TileXtra.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from PIL import Image
from PIL.ImageQt import ImageQt
import numpy as np
import tMat
from fgmk import tMat

abspath = os.path.abspath(__file__)
dname = os.path.dirname(abspath)
Expand Down
4 changes: 1 addition & 3 deletions src/fgmk/actionDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
from PIL import Image
from PIL.ImageQt import ImageQt
import numpy as np
import tMat
import TileXtra
import TXWdgt
from fgmk import tMat, TileXtra, TXWdgt


COLISIONLAYER = 3
Expand Down
63 changes: 63 additions & 0 deletions src/fgmk/actionsWdgt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import sys
import json
import os.path
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5 import QtGui, QtCore, QtWidgets
from PIL import Image
from PIL.ImageQt import ImageQt
import numpy as np
from fgmk import tMat, actionDialog, TileXtra, fifl

class ActionsWidget(QDialog):
def __init__(self, psSettings, parent=None, ischaras=False, **kwargs):
super().__init__(parent, **kwargs)
self.psSettings=psSettings
self.ischaras = ischaras

self.VBox = QVBoxLayout(self)
self.VBox.setAlignment(Qt.AlignTop)

filepath = os.path.join(os.path.dirname(os.path.abspath(__file__)),"actions/actionsList.json")
f = open( filepath, "r" )
e = json.load(f)
f.close()

self.parent = parent
self.actionButton = []

for action in e["actionList"]:
self.actionButton.append(QPushButton(action, self))
self.VBox.addWidget(self.actionButton[-1])
self.actionButton[-1].clicked.connect(self.getAction)

self.setGeometry(300, 40, 350, 650)
self.setWindowTitle('Select Action to add...')

self.show()

def getAction(self):

buttonThatSent = self.sender()
self.returnValue = buttonThatSent.text()

if(self.returnValue == "END" or self.returnValue == "ELSE"):
self.returnValue = [str(self.returnValue),""]
self.accept()
else:
newDialogFromName = getattr(actionDialog, str(self.returnValue))
if(self.ischaras is False):
self.myActionsDialog = newDialogFromName(self.psSettings["gamefolder"],self)
else:
self.myActionsDialog = newDialogFromName(self.psSettings["gamefolder"],self,None,True)

if self.myActionsDialog.exec_() == QtWidgets.QDialog.Accepted:
returnActDlg = str(self.myActionsDialog.getValue())

#self.returnValue.append('|')
self.returnValue = [str(self.returnValue),str(returnActDlg)]
self.accept()

def getValue(self):
return self.returnValue
25 changes: 25 additions & 0 deletions src/fgmk/gameInit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import sys
import json
import os.path
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5 import QtGui, QtCore, QtWidgets
from PIL import Image
from PIL.ImageQt import ImageQt
import numpy as np
from fgmk import tMat, actionDialog, TileXtra, fifl

def selectStartingPosition(parent, psSettings):
myTeleporDialog = actionDialog.teleport(psSettings["gamefolder"],parent, None, False, "select starting position")
if myTeleporDialog.exec_() == QtWidgets.QDialog.Accepted:
returnActDlg = str(myTeleporDialog.getValue())
position=returnActDlg.split(';')
initFileJsonTree = openInitFile(psSettings["gamefolder"])
initFileJsonTree["Player"]["initPosX"] = int(position[0])*32
initFileJsonTree["Player"]["initPosY"] = (int(position[1])-1)*32
if(str(position[2]) != "this"):
initFileJsonTree["World"]["initLevel"] = str(position[2])
else:
initFileJsonTree["World"]["initLevel"] = str(parent.myMap.levelName)
return [initFileJsonTree,str(position[2])]

0 comments on commit 7c93c84

Please sign in to comment.