Ejemplo n.º 1
0
def getUser(username_local, server_name_local):
	#连接服务器
	try:
		sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
		sock.connect((server_name, remote_server_port))
		sock.settimeout(15)
	#检测服务器是否关闭
	except socket.timeout:
		print "Error:timeout"
		return None
	sock.send('{"action":"login","uid":0,"username":"******","ip":"%s"}' %(username_local,server_name_local))
	userdata = sock.recv(1024)
	print userdata
	u = user.user()
	u.set(json.loads(userdata))
	while True:
		print "[FLOATER FIND] try to find fellow"
		sock.send('{"action":"find"}')
		fellow = sock.recv(1024)
		if fellow != "None":
			print "[FLOATER FOUND]", fellow
			userData = json.loads(fellow)
			u.set(userData)
			break
		time.sleep(5)
	sock.send('{"action":"close"}')
	sock.close()
	GUI.setRemote(u)
Ejemplo n.º 2
0
 def __destroyMainWindow(self):
     if self.__window.parent is not None:
         self.__window.parent.delChild(self.__window)
     else:
         GUI.delRoot(self.__window)
     self.__window = None
     return
	def updateState( self, dTime ):		
		GUI.update( dTime )
		self.cc.update( dTime )
		BigBang.update( dTime )
		BigBang.camera().update( dTime )
		BigBang.fudgeOrthographicMode( 1500.0, 0.01 )
		return 1
Ejemplo n.º 4
0
	def draw(self):

		updateInterval = 1.0/(2**self.speed)
		if time.time() - self.lastUpdate > updateInterval and self.running:
			self.lastUpdate = time.time()

			start = time.time()

			for i in range(0,self.skip+1):
				self.sim.update()

			#print("Updating ",time.time()-start)

		start = time.time()

		self.draw_simulation()

		#print("Rendering ",time.time()-start)

		# Draw an outline around the world
		top_right = self.local_to_screen((self.sim.size,self.sim.size))
		bottom_left = self.local_to_screen((0,0))
		GUI.draw_rect_outline (bottom_left[0],bottom_left[1],top_right[0]-bottom_left[0],top_right[1]-bottom_left[1],80)

		self.gui.draw()
Ejemplo n.º 5
0
def showFDFont():
    s = GUI.Simple('')
    s.position = (0, 0, 0)
    GUI.addRoot(s)
    s.materialFX = 'SOLID'
    s.textureName = 'fantasydemofont_20_font_rt'
    s.size = (2, 2)
Ejemplo n.º 6
0
 def buttonClicked(self):
     t = GUI.Text('Button Clicked!')
     t.colour = (255, 0, 0, 255)
     t.position.y = 0.85
     t.verticalAnchor = 'TOP'
     GUI.addRoot(t)
     BigWorld.callback(2.5, partial(_deleteComponent, t))
Ejemplo n.º 7
0
def _displayGUI(spaceName):
    global g_gui
    _clearGUI()
    g_gui = GUI.Text("Entering offline space '%s'...\n%s" % (spaceName, INSTRUCTIONS))
    g_gui.multiline = True
    g_gui.horizontalAnchor = 'CENTER'
    GUI.addRoot(g_gui)
Ejemplo n.º 8
0
 def __onMenuShow(self, mouseUsedForShow):
     if not self.__ingameMenuIsVisible():
         screenWidth = BigWorld.screenWidth()
         screenHeight = BigWorld.screenHeight()
         guiScreenWidth, guiScreenHeight = GUI.screenResolution()
         ratioWidth = float(guiScreenWidth / screenWidth)
         ratioHeight = float(guiScreenHeight / screenHeight)
         self.call('RadialMenu.setRatio', [ratioWidth, ratioHeight])
         crosshairType = self.__getCrosshairType()
         keys = self.__getKeysList(crosshairType)
         self.GUICtrl.setFireKeyCode(self.__getFireKeyCode())
         self.GUICtrl.setState(crosshairType)
         self.GUICtrl.updateKeys(keys)
         screenWidth, screenHeight = GUI.screenResolution()
         ctrl = g_sessionProvider.shared.crosshair
         if ctrl is not None:
             mouseLeft, mouseTop = ctrl.getOffset()
         else:
             mouseLeft, mouseTop = (0.0, 0.0)
         x = round(screenWidth / 2.0 * mouseLeft)
         y = -round(screenHeight / 2.0 * mouseTop)
         offset = (x, y)
         self.__showed = True
         self.GUICtrl.show(offset, mouseUsedForShow)
     return
 def on_init(self, controller):
     print "Initialized"
     self.circleCount = 0;
     self.window = None; 
     self.menu = None;
     self.menu_window = None;
     GUI.init()
Ejemplo n.º 10
0
def launch(spaceName):
    global g_offlineModeEnabled
    global g_spaceID
    global g_videoCamera
    print 'Entering offline space', spaceName
    BigWorld.clearAllSpaces()
    BigWorld.worldDrawEnabled(False)
    _displayGUI(spaceName)
    g_spaceID = BigWorld.createSpace()
    BigWorld.addSpaceGeometryMapping(g_spaceID, None, spaceName)
    BigWorld.setCursor(GUI.mcursor())
    GUI.mcursor().visible = False
    GUI.mcursor().clipped = True
    g_offlineModeEnabled = True
    BigWorld.callback(1.0, _offlineLoadCheck)
    rootSection = ResMgr.openSection(AvatarInputHandler._INPUT_HANDLER_CFG)
    videoSection = rootSection['videoMode']
    videoCameraSection = videoSection['camera']
    g_videoCamera = VideoCamera(videoCameraSection)
    g_videoCamera.enable(camMatrix=mathUtils.createTranslationMatrix((0.0, 0.0, 0.0)))
    BigWorld.camera().spaceID = g_spaceID
    import game
    game.handleKeyEvent = handleKeyEvent
    game.handleMouseEvent = handleMouseEvent
    BigWorld.player = lambda : g_fakeAvatar
    return
Ejemplo n.º 11
0
def showFDFont():
    s = GUI.Simple("")
    s.position = (0, 0, 0)
    GUI.addRoot(s)
    s.materialFX = "SOLID"
    s.textureName = "fantasydemofont_20_font_rt"
    s.size = (2, 2)
Ejemplo n.º 12
0
def play_game():

    player_action = None

    GameState.mouse = libtcod.Mouse()
    GameState.key = libtcod.Key()
    #main loop
    while not libtcod.console_is_window_closed():
        libtcod.sys_check_for_event(libtcod.EVENT_KEY_PRESS | libtcod.EVENT_MOUSE, GameState.key, GameState.mouse)
        #render the screen
        GUI.render_all()

        libtcod.console_flush()

        #level up if needed
        check_level_up()

        #erase all objects at their old locations, before they move
        for object in GameState.objects:
            object.clear()

        #handle keys and exit game if needed
        player_action = handle_keys()
        if player_action == 'exit':
            save_game()
            break

        #let monsters take their turn
        if GameState.game_state == 'playing' and player_action != 'didnt-take-turn':
            for object in objects:
                if object.ai:
                    object.ai.take_turn()
Ejemplo n.º 13
0
def forceShowCursor(show):
    if show:
        BigWorld.setCursor(GUI.mcursor())
        GUI.mcursor().visible = True
    else:
        BigWorld.setCursor(BigWorld.dcursor())
        GUI.mcursor().visible = False
Ejemplo n.º 14
0
def new_game():
    global player, inventory, game_msgs, game_state, dungeon_level

    #create object representing the player
    entity_component = Entity(5)
    GameState.player = Object(0, 0, '@', 'player', libtcod.white, blocks=True, entity=entity_component)

    GameState.player.level = 1

    #generate map (at this point it's not drawn to the screen)
    dungeon_level = 1
    Map.make_map()
    initialize_fov()

    game_state = 'playing'
    GameState.inventory = []

    #create the list of game messages and their colors, starts empty
    GameState.game_msgs = []

    #a warm welcoming message!
    GUI.message('Welcome stranger! Prepare to perish in the Tombs of the Ancient Kings.', libtcod.red)

    #initial equipment: a dagger
    equipment_component = Equipment(slot='right hand', power_bonus=2)
    obj = Object(0, 0, '-', 'dagger', libtcod.sky, equipment=equipment_component)
    GameState.inventory.append(obj)
    equipment_component.equip()
    obj.always_visible = True
Ejemplo n.º 15
0
 def __init__(self, config):
     self.text = config.get('text', '')
     if config.get('color', False):
         self.color = '\c' + config.get('color')[1:] + 'FF;'
     self.visible = config.get('visible', True)
     self.x  = config.get('x', 0)
     self.y  = config.get('y', 0)
     self.hcentered  = config.get('hcentered', False)
     self.vcentered  = config.get('vcentered', False)
     background = os.path.join('scripts', 'client', 'mods', config.get('background')) \
         if config.get('background', '') else ''
     self.window = GUI.Window(background)
     self.window.materialFX = "BLEND"
     self.window.verticalAnchor = "TOP"
     self.window.horizontalAnchor = "LEFT"
     self.window.horizontalPositionMode = 'PIXEL'
     self.window.verticalPositionMode = 'PIXEL'
     self.window.heightMode = 'PIXEL'
     self.window.widthMode = 'PIXEL'
     self.window.width = config.get('width', 186)
     self.window.height = config.get('height', 32)
     GUI.addRoot(self.window)
     self.shadow = GUI.Text('')
     font = config.get('font', 'default_medium.font')
     self.installItem(self.shadow, font)
     self.label = GUI.Text('')
     self.installItem(self.label, font)
     self.setVisible(self.visible)
Ejemplo n.º 16
0
	def __init__(self, parent, describtion="Working..."):
		self.parent = parent

		# init popup dialog
		GUI.Toplevel.__init__(self, parent, takefocus=True)
		self.wm_title(describtion)
		self.transient(parent)
		self.resizable(0,0)

		# add some text
		label = GUI.Label(self, text="progress:")
		label.pack(fill='both', expand=1, padx=2, pady=2)

		# init progress bar
		self.progress_bar = GUI.Progressbar(self, orient='horizontal', length=300, mode='determinate')
		self.progress_bar.pack(fill='both', expand=1, padx=2, pady=2)

		# put window in front of others (popup-action)
		self.lift()
		self.grab_set()
		self.focus_set()
		self.set_maximum(100)
		self.set_progress(0)

		# center window into the center of the parent window
		GUI.center_window(self, parent)
Ejemplo n.º 17
0
def testResize2():
    t2 = GUI.Text('resizebgman')
    t2.font = 'resize.font'
    GUI.addRoot(t2)
    t2.verticalAnchor = 'TOP'
    fontTestGUIs.append(t2)
    return t2
Ejemplo n.º 18
0
def testResize2():
    t2 = GUI.Text("resizebgman")
    t2.font = "resize.font"
    GUI.addRoot(t2)
    t2.verticalAnchor = "TOP"
    fontTestGUIs.append(t2)
    return t2
Ejemplo n.º 19
0
    def rebuild(self):
        saved_parent = self.getParent()
        saved_position = self.getPosition()
        saved_size = self.getSize()
        saved_textureName = self.getTextureName()
        saved_visible = self.getVisible()
        for curItem in self.__dictItems.itervalues():
            self.__window.delChild(curItem._guiName)
            self.__window.delChild(curItem._guiValue)

        GUI.delRoot(self.__window)
        self.__window = None
        for curItem in self.__dictItems.itervalues():
            curItem._rebuild()

        self.__createMainWindow(saved_parent)
        self.setPosition(saved_position)
        self.setSize(saved_size)
        self.setTextureName(saved_textureName)
        self.setVisible(saved_visible)
        for curItem in self.__dictItems.itervalues():
            self.__window.addChild(curItem._guiName)
            self.__window.addChild(curItem._guiValue)

        if self.__bAutoUpdate:
            self.update()
        return
Ejemplo n.º 20
0
Archivo: main.py Proyecto: szx/YAPGU
def start(argv):
    graphics.assetDirectory('assets')
    sprite = graphics.Sprite("sprite.png", Vector2D(100.0,100.0), frames=9)
    button = GUI.Button("button.png", Vector2D(200.0,100.0))
    def drawFunc():
        sprite.draw()
        button.draw()
        graphics.drawText("Works!", Vector2D(80.0,550.0), Color(0,0,255))
    graphics.init(800, 600, drawFunc)
    inputf.init()
    GUI.init()
    
    def movementMicrothread():
        while True:
            if inputf.keyboard[inputf.key.UP]:
                sprite.position.y += 10 * logic.delta()
            if inputf.mouse.left:
                sprite.position.x += 10 * logic.delta()
            #else:
            #    sprite.position.x -= 10 * logic.delta()
            if inputf.mouse.inRect(sprite):
                sprite.position.y -= 10 * logic.delta()
            microthreads.schedule()
    microthreads.microthread(movementMicrothread)
    
    logic.start()
    
Ejemplo n.º 21
0
def launch(spaceName):
    global g_enablePostProcessing
    global g_offlineModeEnabled
    print 'Entering offline space', spaceName
    BigWorld.clearAllSpaces()
    BigWorld.worldDrawEnabled(False)
    _displayGUI(spaceName)
    spaceID = BigWorld.createSpace()
    BigWorld.addSpaceGeometryMapping(spaceID, None, spaceName)
    _loadCameraTransforms()
    camera = BigWorld.FreeCamera()
    camera.spaceID = spaceID
    BigWorld.camera(camera)
    _setCameraTransform(g_curCameraTransform)
    BigWorld.camera().fixed = True
    BigWorld.projection().fov = math.radians(75.0)
    BigWorld.setWatcher('Client Settings/Strafe Rate', 175.0)
    BigWorld.setWatcher('Client Settings/Camera Mass', 5.0)
    BigWorld.setCursor(GUI.mcursor())
    GUI.mcursor().visible = True
    GUI.mcursor().clipped = False
    g_offlineModeEnabled = True
    BigWorld.callback(1.0, _offlineLoadCheck)
    g_postProcessing.init()
    _enablePostProcessing(g_enablePostProcessing, 'arcade')
    return
Ejemplo n.º 22
0
 def __destroyGUI(self):
     assert self._guiName.parent is None
     assert self._guiValue.parent is None
     GUI.delRoot(self._guiName)
     self._guiName = None
     GUI.delRoot(self._guiValue)
     self._guiValue = None
Ejemplo n.º 23
0
def testResize1():
    t = GUI.Text('resize')
    t.font = 'resize.font'
    GUI.addRoot(t)
    fontTestGUIs.append(t)
    t.verticalAnchor = 'BOTTOM'
    _showFont('resize.font')
    return t
Ejemplo n.º 24
0
def testResize1():
    t = GUI.Text("resize")
    t.font = "resize.font"
    GUI.addRoot(t)
    fontTestGUIs.append(t)
    t.verticalAnchor = "BOTTOM"
    _showFont("resize.font")
    return t
Ejemplo n.º 25
0
def testWindow():
    BigWorld.camera(BigWorld.CursorCamera())
    BigWorld.setCursor(GUI.mcursor())
    GUI.mcursor().visible = True
    clear()
    w = GUI.load('gui/tests/window.gui')
    GUI.addRoot(w)
    return w
Ejemplo n.º 26
0
 def __createMainWindow(self, parentGUI):
     self.__window = GUI.Window()
     self.__window.horizontalAnchor = 'LEFT'
     self.__window.verticalAnchor = 'TOP'
     if parentGUI is None:
         GUI.addRoot(self.__window)
     else:
         parentGUI.addChild(self.__window)
Ejemplo n.º 27
0
 def use(self):
     if self.owner.equipment:
         self.owner.equipment.toggle_equip()
         return
     if(self.use_function != None):
         self.use_function()
     else:
         GUI.message("That doesn't do anything (yet)")
Ejemplo n.º 28
0
 def active(self, state):
     if self.isActive != state:
         self.isActive = state
         if state:
             GUI.addRoot(self.component)
             self.component.size = self.flashSize
         else:
             GUI.delRoot(self.component)
	def render( self, dTime ):
		"""This function forces World Editor to render everything on the scene. 
		Usually called everyframe, however it still recieves a dTime value which 
		informs the renderer how much time has passed since the last render	call."""
		WorldEditor.camera().render( dTime )
		WorldEditor.render( dTime )
		GUI.draw()
		return 1
Ejemplo n.º 30
0
 def __destroyGUI(self):
     raise self._guiName.parent is None or AssertionError
     raise self._guiValue.parent is None or AssertionError
     GUI.delRoot(self._guiName)
     self._guiName = None
     GUI.delRoot(self._guiValue)
     self._guiValue = None
     return
Ejemplo n.º 31
0
import Algorithm as Al
import Console
import GUI

# Main
grid = Al.createGrid(30, 30)

buttonsGrid = GUI.buttonsGrid(grid)
GUI.openWindow(buttonsGrid, grid)

#for i in range(0, 4):
#Console.paintGrid(grid)
#grid = Al.newGeneration(grid)
#Console.paintGrid(grid)
Ejemplo n.º 32
0
 def handleMouseLeaveEvent(self, comp):
     self.webPage.allowCursorInteraction(False)
     GUI.mcursor().automaticCursorManagement = self.prevCursorManagement
     return True
Ejemplo n.º 33
0
def main():
    """Создание и вызов главного окна"""
    app = QApplication(sys.argv)
    mw = GUI.MainWindow()
    sys.exit(app.exec_())
Ejemplo n.º 34
0
## 2017.0.04 Initial  ##

# -*- coding: utf-8 -*-

import wx
import wx.xrc
import GUI

if __name__ == '__main__':
    app = wx.App()
    main_win = GUI.MyFrame(None)
    main_win.Show()
    main_win.ShowSerial(None)
    app.MainLoop()
Ejemplo n.º 35
0
 def handleMouseEnterEvent(self, comp):
     self.prevCursorManagement = GUI.mcursor().automaticCursorManagement
     GUI.mcursor().automaticCursorManagement = False
     self.webPage.allowCursorInteraction(True)
     return True