Beispiel #1
0
def launch(argsList=None):
    """
    Opens the mod's help file or web page externally if it can be found or displays an error alert.
    
    On Windows this opens the compiled HTML help file (CHM).
    On Mac this opens a browser window to the online help file.
    """
    if BugPath.isMac():
        sLang = ["ENG", "ENG", "DEU", "ITA", "ENG"]
        url = "http://civ4bug.sourceforge.net/BUGModHelp/%s/index.htm" % sLang[CyGame().getCurrentLanguage()]
        try:
            import webbrowser
            showLaunchMessage()
            webbrowser.open(url, new=1, autoraise=1)
            return True
        except:
            showErrorAlert(BugUtil.getPlainText("TXT_KEY_BUG_HELP_CANNOT_OPEN_BROWSER_TITLE"), 
                    BugUtil.getText("TXT_KEY_BUG_HELP_CANNOT_OPEN_BROWSER_BODY", (url,)))       
    else:
        sLang = ["ENG", "FRA", "DEU", "ITA", "ESP"]
        name = "BUG Mod Help-%s.chm" % (sLang[CyGame().getCurrentLanguage()])
        file = BugPath.findInfoFile(name)
        if file:
            import os
            message = BugUtil.getPlainText("TXT_KEY_BUG_HELP_OPENING")
            CyInterface().addImmediateMessage(message, "")
            os.startfile(file)
            return True
        else:
            showErrorAlert(BugUtil.getPlainText("TXT_KEY_BUG_HELP_MISSING_TITLE"), 
                    BugUtil.getText("TXT_KEY_BUG_HELP_MISSING_BODY", (name,)))
    return False
Beispiel #2
0
def init():
    """
	Checks for the presence of the BUFFY DLL and sets the global flags.
	"""
    if isEnabled():
        if BugPath.isMac():
            BugUtil.debug("BUFFY is not active on Mac (no DLL)")
        else:
            try:
                if gc.isBuffy():
                    global IS_DLL_PRESENT, IS_DLL_IN_CORRECT_PATH, IS_ACTIVE
                    IS_DLL_PRESENT = True
                    IS_ACTIVE = True
                    BugUtil.info("BUFFY is active (API version %d)",
                                 gc.getBuffyApiVersion())
                    try:
                        dllPath = gc.getGame().getDLLPath()
                        exePath = gc.getGame().getExePath()
                        dllPathThenUp3 = os.path.dirname(
                            os.path.dirname(os.path.dirname(dllPath)))
                        if dllPathThenUp3 == exePath:
                            IS_DLL_IN_CORRECT_PATH = True
                    except:
                        pass  # DLL path is borked
            except:
                BugUtil.info("BUFFY is not active (no DLL)")
def launch(argsList=None):
	"""
	Opens the mod's help file or web page externally if it can be found or displays an error alert.
	
	On Windows this opens the compiled HTML help file (CHM).
	On Mac this opens a browser window to the online help file.
	"""
	if BugPath.isMac():
		sLang = ["ENG", "ENG", "DEU", "ITA", "ENG"]
		url = "http://civ4bug.sourceforge.net/BUGModHelp/%s/index.htm" % sLang[CyGame().getCurrentLanguage()]
		try:
			import webbrowser
			showLaunchMessage()
			webbrowser.open(url, new=1, autoraise=1)
			return True
		except:
			showErrorAlert(BugUtil.getPlainText("TXT_KEY_BUG_HELP_CANNOT_OPEN_BROWSER_TITLE"), 
					BugUtil.getText("TXT_KEY_BUG_HELP_CANNOT_OPEN_BROWSER_BODY", (url,)))		
	else:
		sLang = ["ENG", "FRA", "DEU", "ITA", "ESP"]
		name = "BUG Mod Help-%s.chm" % (sLang[CyGame().getCurrentLanguage()])
		file = BugPath.findInfoFile(name)
		if file:
			import os
			message = BugUtil.getPlainText("TXT_KEY_BUG_HELP_OPENING")
			CyInterface().addImmediateMessage(message, "")
			os.startfile(file)
			return True
		else:
			showErrorAlert(BugUtil.getPlainText("TXT_KEY_BUG_HELP_MISSING_TITLE"), 
					BugUtil.getText("TXT_KEY_BUG_HELP_MISSING_BODY", (name,)))
	return False
	def eraseDot(self, city, alpha):
		"""
		Erases the dot for a single city.
		"""
		if self.DRAW_DOTS:
			x, y = city.point
			if BugPath.isMac():
				CyEngine().addColoredPlot(x, y, self.INVISIBLE_COLOR, self.DOT_LAYER)
			else:
				CyEngine().addColoredPlotAlt(x, y, self.NO_DOT_STYLE, self.DOT_LAYER, "COLOR_BLACK", alpha)
Beispiel #5
0
	def eraseDot(self, city, alpha):
		"""
		Erases the dot for a single city.
		"""
		if self.DRAW_DOTS:
			x, y = city.point
			if BugPath.isMac():
				CyEngine().addColoredPlot(x, y, self.INVISIBLE_COLOR, self.DOT_LAYER)
			else:
				CyEngine().addColoredPlotAlt(x, y, self.NO_DOT_STYLE, self.DOT_LAYER, "COLOR_BLACK", alpha)
	def drawDot(self, city, alpha):
		"""
		Draws the dot for a single city.
		"""
		if self.DRAW_DOTS:
			x, y = city.point
			colorInfo = gc.getColorInfo(city.color)
			if BugPath.isMac():
				color = colorInfo.getColor()
				CyEngine().addColoredPlot(x, y, NiColorA(color.r, color.g, color.b, alpha), self.DOT_LAYER)
			else:
				CyEngine().addColoredPlotAlt(x, y, self.DOT_STYLE, self.DOT_LAYER, colorInfo.getType(), alpha)
Beispiel #7
0
	def drawDot(self, city, alpha):
		"""
		Draws the dot for a single city.
		"""
		if self.DRAW_DOTS:
			x, y = city.point
			colorInfo = gc.getColorInfo(city.color)
			if BugPath.isMac():
				color = colorInfo.getColor()
				CyEngine().addColoredPlot(x, y, NiColorA(color.r, color.g, color.b, alpha), self.DOT_LAYER)
			else:
				CyEngine().addColoredPlotAlt(x, y, self.DOT_STYLE, self.DOT_LAYER, colorInfo.getType(), alpha)
Beispiel #8
0
def initAfterReload():
	"""
	Initialize BUG and fires PythonReloaded event after reloading Python modules while game is still running.
	
	The first time this module is loaded after the game launches, the global context is not yet ready,
	and thus BUG cannot be initialized. When the Python modules are reloaded after being changed, however,
	this will reinitialize BUG and the main interface.
	"""
	import BugInit
	import BugPath
	if not BugPath.isMac() and BugInit.init():
		try:
			import CvScreensInterface
			CvScreensInterface.reinitMainInterface()
		except:
			import BugUtil
			BugUtil.error("BugInit - failure rebuilding main interface after reloading Python modules")
		getEventManager().fireEvent("PythonReloaded")
Beispiel #9
0
def initAfterReload():
	"""
	Initialize BUG and fires PythonReloaded event after reloading Python modules while game is still running.
	
	The first time this module is loaded after the game launches, the global context is not yet ready,
	and thus BUG cannot be initialized. When the Python modules are reloaded after being changed, however,
	this will reinitialize BUG and the main interface.
	"""
	import BugInit
	import BugPath
	if not BugPath.isMac() and BugInit.init():
		try:
			import CvScreensInterface
			CvScreensInterface.reinitMainInterface()
		except:
			import BugUtil
			BugUtil.error("BugInit - failure rebuilding main interface after reloading Python modules")
		getEventManager().fireEvent("PythonReloaded")
Beispiel #10
0
def init():
    """
	Checks for the presence of the BUFFY DLL and sets the global flags.
	"""
    if isEnabled():
        if BugPath.isMac():
            BugUtil.debug("BUFFY is not active on Mac (no DLL)")
        else:
            try:
                if gc.isBuffy():
                    global IS_DLL_PRESENT, IS_DLL_IN_CORRECT_PATH, IS_ACTIVE
                    IS_DLL_PRESENT = True
                    IS_ACTIVE = True
                    BugUtil.info("BUFFY is active (API version %d)", gc.getBuffyApiVersion())
                    try:
                        dllPath = gc.getGame().getDLLPath()
                        exePath = gc.getGame().getExePath()
                        dllPathThenUp3 = os.path.dirname(os.path.dirname(os.path.dirname(dllPath)))
                        if dllPathThenUp3 == exePath:
                            IS_DLL_IN_CORRECT_PATH = True
                    except:
                        pass  # DLL path is borked
            except:
                BugUtil.info("BUFFY is not active (no DLL)")