コード例 #1
0
    // Use this for initialization
    public ServerCoordEffects()
    {
        functionName = "Coord Effects";
        // Database tables name
        tableName = "coordinated_effects";
        functionTitle = "Coord Effects Configuration";
        loadButtonLabel = "Load Coord Effects";
        notLoadedText = "No Coord Effects loaded.";
        // Init
        dataRegister = new Dictionary<int, CoordEffectData> ();

        editingDisplay = new CoordEffectData ();
        originalDisplay = new CoordEffectData ();
    }
コード例 #2
0
    // Edit or Create
    public override void DrawEditor(Rect box, bool newItem)
    {
        // Setup the layout
        Rect pos = box;
        pos.x += ImagePack.innerMargin;
        pos.y += ImagePack.innerMargin;
        pos.width -= ImagePack.innerMargin;
        pos.height = ImagePack.fieldHeight;

        // Draw the content database info
        //pos.y += ImagePack.fieldHeight;

        if (newItem) {
            ImagePack.DrawLabel (pos.x, pos.y, "Create a new Coord Effect");
            pos.y += ImagePack.fieldHeight;
        }

        editingDisplay.name = ImagePack.DrawField (pos, "Name:", editingDisplay.name, 0.75f);
        pos.y += ImagePack.fieldHeight;
        editingDisplay.prefab = ImagePack.DrawGameObject (pos, "Game Object:", editingDisplay.prefab, 0.75f);

        pos.y += 2.5f * ImagePack.fieldHeight;
        // Save data
        pos.x -= ImagePack.innerMargin;
        pos.width /= 3;
        if (ImagePack.DrawButton (pos.x, pos.y, "Save Data")) {
            if (newItem)
                InsertEntry ();
            else
                UpdateEntry ();

            state = State.Loaded;
        }

        // Delete data
        if (!newItem) {
            pos.x += pos.width;
            if (ImagePack.DrawButton (pos.x, pos.y, "Delete Data")) {
                DeleteEntry ();
                newSelectedDisplay = 0;
                state = State.Loaded;
            }
        }

        // Cancel editing
        pos.x += pos.width;
        if (ImagePack.DrawButton (pos.x, pos.y, "Cancel")) {
            editingDisplay = originalDisplay.Clone();
            if (newItem)
                state = State.New;
            else
                state = State.Loaded;
        }

        if (resultTimeout != -1 && resultTimeout > Time.realtimeSinceStartup) {
            pos.y += ImagePack.fieldHeight;
            ImagePack.DrawText(pos, result);
        }
    }
コード例 #3
0
 public override void CreateNewData()
 {
     editingDisplay = new CoordEffectData ();
     originalDisplay = new CoordEffectData ();
     selectedDisplay = -1;
 }
コード例 #4
0
    // Load Database Data
    public override void Load()
    {
        if (!dataLoaded) {
            // Clean old data
            dataRegister.Clear ();
            displayKeys.Clear ();

            // Read all entries from the table
            string query = "SELECT * FROM " + tableName;

            // If there is a row, clear it.
            if (rows != null)
                rows.Clear ();

            // Load data
            rows = DatabasePack.LoadData (DatabasePack.contentDatabasePrefix, query);
            //Debug.Log("#Rows:"+rows.Count);
            // Read all the data
            int fakeId = 0;
            if ((rows!=null) && (rows.Count > 0)) {
                foreach (Dictionary<string,string> data in rows) {
                    //foreach(string key in data.Keys)
                    //	Debug.Log("Name[" + key + "]:" + data[key]);
                    //return;
                    CoordEffectData display = new CoordEffectData ();
                    // As we don have a primary key ID field
                    fakeId++;
                    display.id = fakeId;
                    display.name = data ["name"];
                    display.prefab = data ["prefab"];

                    display.isLoaded = true;
                    //Debug.Log("Name:" + display.name  + "=[" +  display.id  + "]");
                    dataRegister.Add (display.id, display);
                    displayKeys.Add (display.id);
                }
                LoadSelectList();
            }
            dataLoaded = true;
        }
    }
コード例 #5
0
    // Draw the loaded list
    public override void DrawLoaded(Rect box)
    {
        // Setup the layout
        Rect pos = box;
        pos.x += ImagePack.innerMargin;
        pos.y += ImagePack.innerMargin;
        pos.width -= ImagePack.innerMargin;
        pos.height = ImagePack.fieldHeight;

        if (dataRegister.Count <= 0) {
            pos.y += ImagePack.fieldHeight;
            ImagePack.DrawLabel (pos.x, pos.y, "You must create a Coordinated Effect before editing it.");
            return;
        }

        // Draw the content database info
        ImagePack.DrawLabel (pos.x, pos.y, "Coord Effect Configuration");

        if (newItemCreated) {
            newItemCreated = false;
            LoadSelectList();
            newSelectedDisplay = displayKeys.Count - 1;
        }

        // Draw data Editor
        if (newSelectedDisplay != selectedDisplay) {
        selectedDisplay = newSelectedDisplay;
        int displayKey = displayKeys [selectedDisplay];
        editingDisplay = dataRegister [displayKey];
            originalDisplay = editingDisplay.Clone();
        }

        //if (!displayList.showList) {
            pos.y += ImagePack.fieldHeight;
            pos.x -= ImagePack.innerMargin;
            pos.y -= ImagePack.innerMargin;
            pos.width += ImagePack.innerMargin;
            DrawEditor (pos, false);
            pos.y -= ImagePack.fieldHeight;
            //pos.x += ImagePack.innerMargin;
            pos.y += ImagePack.innerMargin;
            pos.width -= ImagePack.innerMargin;
        //}

                if (state != State.Loaded) {
        // Draw combobox
        pos.width /= 2;
        pos.x += pos.width;
        newSelectedDisplay = ImagePack.DrawCombobox (pos, "", selectedDisplay, displayList);
        pos.x -= pos.width;
        pos.width *= 2;
        }
    }