Exemplo n.º 1
0
 public void _on_BackButton_pressed()
 {
     GDKnyttSettings.saveSettings();
     TouchSettings.applyAllSettings(GetTree());
     ClickPlayer.Play();
     this.QueueFree();
 }
Exemplo n.º 2
0
    public UserMovesInterpreter(TouchSettings settings)
    {
        this.settings = settings;
        TouchManager.Instance.TouchesBegan += TouchesBegan;
        TouchManager.Instance.TouchesCancelled += TouchesEnded;
        TouchManager.Instance.TouchesEnded += TouchesEnded;
        TouchManager.Instance.TouchesMoved += TouchesMoves;

        var borderWidth = Screen.width * settings.percentageSwipeArea / 100;
        var leftBorder = new Rect(0f, 0f, borderWidth, Screen.height);
        lefSwipeInterpreter = new SwipeInterpreter(new Vector2(1.0f, 0), settings.swipeAngle, settings.swipeDistance, leftBorder);
        lefSwipeInterpreter.Swipe += () => { if (swipe != null) swipe(-1); };

        var rightBorder = new Rect(Screen.width - borderWidth, 0f, borderWidth, Screen.height);
        rightSwipeInterpreter = new SwipeInterpreter(new Vector2(-1.0f, 0), settings.swipeAngle, settings.swipeDistance, rightBorder);
        rightSwipeInterpreter.Swipe += () => { if (swipe != null) swipe(1); };

        var pinchRect = new Rect(borderWidth, 0, Screen.width - borderWidth, Screen.height);
        pinchInterpreter = new PinchInterpreter(pinchRect,settings.zoomInDistance, settings.zoomOutDistance);
        pinchInterpreter.ZoomIn += () => { if (zoomIn != null) zoomIn(); };
        pinchInterpreter.ZoomOut += () => { if (zoomOut != null) zoomOut(); };

        panListener = new PanInterpreter(pinchRect);
        panListener.OnPan+= vector2 => { if (panGesture != null) panGesture(vector2);};
    }
Exemplo n.º 3
0
    private static void initialize()
    {
        bool modified = false;

        // Try to load the settings file
        modified |= loadSettings();

        modified |= ensureSetting("Graphics", "Fullscreen", "0");
        modified |= ensureSetting("Graphics", "Smooth Scaling", "0");
        modified |= ensureSetting("Graphics", "Scroll Type", "Smooth");

        modified |= ensureSetting("Audio", "Master Volume", "100");
        modified |= ensureSetting("Audio", "Music Volume", "80");
        modified |= ensureSetting("Audio", "Effects Volume", "70");
        modified |= ensureSetting("Audio", "Environment Volume", "80");

        modified |= ensureSetting("Server", "URL", "http://yknytt.herokuapp.com");

        modified |= TouchSettings.ensureSettings();

        if (modified)
        {
            saveSettings();
        }
        applyAllSettings();
    }
Exemplo n.º 4
0
 public static void Update()
 {
     configTable = new Dictionary <string, object>()
     {
         { Defines.TouchConfig, TouchSettings.GetConfig() },
         { Defines.GameConfig, GameSettingsScreen.GetConfig() }
     };
 }
Exemplo n.º 5
0
    private static void initialize()
    {
        bool modified = false;

        // Try to load the settings file
        modified |= loadSettings();

        modified |= ensureSetting("Graphics", "Fullscreen", "0");
        modified |= ensureSetting("Graphics", "Smooth Scaling", "0");
        modified |= ensureSetting("Graphics", "Scroll Type", "Smooth");

        modified |= TouchSettings.ensureSettings();

        if (modified)
        {
            saveSettings();
        }
        applyAllSettings();
    }
Exemplo n.º 6
0
    public static bool Load(string filepath = "")
    {
        if (!String.IsNullOrEmpty(filepath))
        {
            FilePath = filepath;
        }

        // build defaults
        if (!File.Exists(Defines.ConfigFile))
        {
            CreateConfigFile();
        }

        configTable = Toml.ReadFile(Defines.ConfigFile).ToDictionary();

        if (File.Exists(Defines.LanguageConfig))
        {
            localizationTable = Toml.ReadFile(Defines.LanguageConfig).ToDictionary();
        }

        // Set the localized language for the rest of the run, unless changed in options
        if (configTable.ContainsKey(Defines.GameConfig))
        {
            Dictionary <string, object> gameOpts = (Dictionary <string, object>)configTable["GameConfig"];
            if (gameOpts.ContainsKey("Language"))
            {
                SetLocalizedLanguage(Convert.ToInt32(gameOpts["Language"]));
            }
        }

        if (configTable.ContainsKey(Defines.TouchConfig))
        {
            TouchSettings.SetConfig((Dictionary <string, object>)configTable[Defines.TouchConfig]);
        }

        IsLoaded = true;
        return(true);
    }
Exemplo n.º 7
0
    public static bool Load(string filepath = "")
    {
        if (!String.IsNullOrEmpty(filepath))
        {
            FilePath = filepath;
        }

        // build defaults
        if (!File.Exists(Defines.ConfigFile))
        {
            CreateConfigFile();
        }

        configTable = Toml.ReadFile(Defines.ConfigFile).ToDictionary();

        if (configTable.ContainsKey(Defines.TouchConfig))
        {
            TouchSettings.SetConfig((Dictionary <string, object>)configTable[Defines.TouchConfig]);
        }

        IsLoaded = true;
        return(true);
    }