Ejemplo n.º 1
0
ANDR_DSN = 'http://247716acba64489e9165dd294491248b' \
           ':[email protected]/4'
DESK_DSN = 'http://90be6086bef6448aa6cdba1a9f7abebe' \
           ':[email protected]/5'

features.add_feature('debug.dsn',
                     default=DESK_DSN if osutil.is_desktop else ANDR_DSN,
                     type=bool)


def apply_hardexit(t):
    client.freeciv.hard_exit = t


features.set_applier('app.hardexit', apply_hardexit, type=bool, default=True)

main_menu = None
main_menu_update_shown = False

pause_file = os.path.join(save.get_save_dir(), 'pause_options')


def client_main():
    if try_resume():
        ui.main()
        return

    ui.set(ui.Label('loading...'))
    ui.execute_later(app_main)
Ejemplo n.º 2
0
import features
import save

HOST = 'www.civsync.com'
PROTO = 'https'
USER_AGENT = 'CivGeneric/1'

def apply_host_change(host):
    global HOST
    HOST = host

def apply_proto_change(proto):
    global PROTO
    PROTO = proto

features.set_applier('civsync.host', apply_host_change, default=HOST)
features.set_applier('civsync.proto', apply_proto_change, default=PROTO)

def apply_user_agent_change(ua):
    global USER_AGENT
    USER_AGENT = ua
    # hack, hack, hack
    print 'changing user agent to', ua
    urllib.URLopener.version = ua

features.set_applier('civsync.ua', apply_user_agent_change)
features.set('civsync.ua', 'CivSyncAndroid/1108')
features.add_feature('civsync.enable', False, type=bool)
features.add_feature('civsync.sid', None)

def get_sid():
Ejemplo n.º 3
0
history = []
screen = None
overlays = []

screen_height = 0
screen_width = 0
screen_size = 0, 0

show_fps = False

def set_show_fps(val):
    global show_fps
    show_fps = val

features.set_applier('ui.showfps', set_show_fps, type=bool, default=False)
features.add_feature('ui.enable_anim', type=bool, default=True)

def replace(new_screen):
    global screen
    screen = new_screen

def replace_anim(new_screen, direction=1):
    if features.get('ui.enable_anim'):
        replace(Animation(screen, new_screen, direction))
    else:
        replace(new_screen)

def set(new_screen, anim=True):
    if screen:
        history.append(screen)
Ejemplo n.º 4
0
def new_game():
    save.new_game()

features.add_feature('app.debug', default=True, type=bool)
features.add_feature('app.autoupdate', default=True, type=bool)
features.add_feature('app.forcesize')
features.add_feature('app.resume', default=True, type=bool)
features.add_feature('app.profile', default=False, type=bool)
features.add_feature('app.shutdown', default=10, type=int)
features.add_feature('app.multiplayer', default=False, type=bool)

def apply_hardexit(t):
    client.freeciv.hard_exit = t

features.set_applier('app.hardexit', apply_hardexit, type=bool, default=True)

main_menu = None
main_menu_update_shown = False

pause_file = os.path.join(save.get_save_dir(), 'pause_options')

def client_main():
    action = sys.argv[1] if sys.argv[1:] else None
    if try_resume():
        ui.main()
        return
    
    if action == 'load':
        savename = sys.argv[2]
        save.load_game(savename)
Ejemplo n.º 5
0
import functools
import features

import osutil
import civsync
import ui
import uidialog
import save


def apply_host_change(host):
    print 'using civsync host', host
    civsync.HOST = host


features.set_applier('civsync.host', apply_host_change, default=civsync.HOST)


def apply_user_agent_change(ua):
    civsync.USER_AGENT = ua


features.set_applier('civsync.ua', apply_user_agent_change)
features.set('civsync.ua', 'CivSyncAndroid/1104')
features.add_feature('civsync.enable', False, type=bool)

session = None


def show_load():
    request(show_list, 'list')
Ejemplo n.º 6
0
import time

def set_debug(flag):
    global debug
    debug = flag
    
debug = False

def make_init_profiling_tuple():
    return [0, 0.0]

_profiling_callback = collections.defaultdict(make_init_profiling_tuple)
_profiling_calls = collections.defaultdict(make_init_profiling_tuple)

features.add_feature('debug.freeciv.print_callbacks', type=bool, default=False)
features.set_applier('debug.freeciv', set_debug, type=bool, default=False)

class _obj: pass

func = _obj()
callback = _obj()
const = _obj()

hard_exit = True

callback_num = 0

def _callback(funname, *args):
    if debug:
        start_time = time.time()
        if features.get('debug.freeciv.print_callbacks'):
Ejemplo n.º 7
0
screen = None
overlays = []

screen_height = 0
screen_width = 0
screen_size = 0, 0

show_fps = False


def set_show_fps(val):
    global show_fps
    show_fps = val


features.set_applier('ui.showfps', set_show_fps, type=bool, default=False)
features.add_feature('ui.enable_anim', type=bool, default=True)


def replace(new_screen):
    global screen
    screen = new_screen


def replace_anim(new_screen, direction=1):
    if features.get('ui.enable_anim'):
        replace(Animation(screen, new_screen, direction))
    else:
        replace(new_screen)

Ejemplo n.º 8
0
import features
import save

HOST = 'www.civsync.com'
PROTO = 'https'
USER_AGENT = 'CivGeneric/1'

def apply_host_change(host):
    global HOST
    HOST = host

def apply_proto_change(proto):
    global PROTO
    PROTO = proto

features.set_applier('civsync.host', apply_host_change, default=HOST)
features.set_applier('civsync.proto', apply_proto_change, default=PROTO)

def apply_user_agent_change(ua):
    global USER_AGENT
    USER_AGENT = ua
    # hack, hack, hack
    print 'changing user agent to', ua
    urllib.URLopener.version = ua

features.set_applier('civsync.ua', apply_user_agent_change)

version = 1109
if osutil.is_desktop:
    features.set('civsync.ua', 'CivSyncDesktop/%d' % version)
else:
Ejemplo n.º 9
0
except:
    import pyjni

    class lzma:
        def decompress(self, data):
            return pyjni.encode_or_decode_xz(1, data)

        def compress(self, data):
            return pyjni.encode_or_decode_xz(0, data)
    lzma = lzma()

def apply_host_change(host):
    print 'using civsync host', host
    civsync.HOST = host

features.set_applier('civsync.host', apply_host_change, default=civsync.HOST)

def apply_user_agent_change(ua):
    civsync.USER_AGENT = ua

features.set_applier('civsync.ua', apply_user_agent_change)
features.set('civsync.ua', 'CivSyncAndroid/1016')
features.add_feature('civsync.enable', False, type=bool)

session = None

def show_load():
    request(show_list, 'list')

def show_list(entries):
    panel = ui.LinearLayoutWidget()
Ejemplo n.º 10
0
import osutil
import features
from freeciv import sync

import functools
import microjson as json

features.add_feature('gold.enable', type=bool, default=False)
features.add_feature('gold.initiated', type=bool, default=False)


def set_gold_status(status):
    pass


features.set_applier('gold.status', default='none', func=set_gold_status)
features.add_feature('gold.session_warning', type=bool, default=False)


def menu():
    layout = ui.LinearLayoutWidget(marginleft=10)
    buttons = ui.HorizontalLayoutWidget(spacing=10)
    text_label = help.LongTextWidget('Loading...', ui.screen_width,
                                     ui.smallfont)

    layout.add(buttons)
    layout.add(text_label)
    layout.add(buttons)

    ui. async (check_products)
Ejemplo n.º 11
0
from freeciv import sync
from freeciv import help
import osutil
import features
from freeciv import sync

import functools
import microjson as json

features.add_feature('gold.enable', type=bool, default=False)
features.add_feature('gold.initiated', type=bool, default=False)

def set_gold_status(status):
    pass

features.set_applier('gold.status', default='none', func=set_gold_status)
features.add_feature('gold.session_warning', type=bool, default=False)

def menu():
    layout = ui.LinearLayoutWidget(marginleft=10)
    buttons = ui.HorizontalLayoutWidget(spacing=10)
    text_label = help.LongTextWidget('Loading...', ui.screen_width, ui.smallfont)

    layout.add(buttons)
    layout.add(text_label)
    layout.add(buttons)

    ui.async(check_products)

    def text_fetched(text):
        data = json.loads(text)
Ejemplo n.º 12
0
    global debug
    debug = flag


debug = False


def make_init_profiling_tuple():
    return [0, 0.0]


_profiling_callback = collections.defaultdict(make_init_profiling_tuple)
_profiling_calls = collections.defaultdict(make_init_profiling_tuple)

features.add_feature('debug.freeciv.print_callbacks', type=bool, default=False)
features.set_applier('debug.freeciv', set_debug, type=bool, default=False)


class _obj:
    pass


func = _obj()
callback = _obj()
const = _obj()

hard_exit = True

callback_num = 0

Ejemplo n.º 13
0
import freeciv
import window
import sys
import progress
import time
import features

def set_debug(flag):
    if flag:
        realsurf = pygame.Surface
        def make_surf(size, *args):
            print 'make_surf', size
            return realsurf(size, *args)
        pygame.Surface = make_surf

features.set_applier('debug.makesurf', set_debug, type=bool, default=False)

DO_MASK = False

class SpriteSurface(pygame.Surface):
    pass

@freeciv.register
def load_gfxfile(fn):
    if fn.startswith('flags/'):
        return load_flag(fn[len('flags/'):])
    else:
        return pygame.image.load(fn).convert_alpha()

@freeciv.register
def get_sprite_dimensions(image):
Ejemplo n.º 14
0
import time
import features


def set_debug(flag):
    if flag:
        realsurf = pygame.Surface

        def make_surf(size, *args):
            print 'make_surf', size
            return realsurf(size, *args)

        pygame.Surface = make_surf


features.set_applier('debug.makesurf', set_debug, type=bool, default=False)

DO_MASK = False


class SpriteSurface(pygame.Surface):
    pass


@freeciv.register
def load_gfxfile(fn):
    if fn.startswith('flags/'):
        return load_flag(fn[len('flags/'):])
    else:
        return pygame.image.load(fn).convert_alpha()