示例#1
0
    // Use this for initialization
    public ServerOptionChoices()
    {
        functionName = "Option Choices";
        // Database tables name
        tableName = "editor_option";
        functionTitle =  "Option Type Configuration";
        loadButtonLabel =  "Load Option Choices";
        notLoadedText =  "No Option Type loaded.";
        // Init
        dataRegister = new Dictionary<int, AtavismEditorOption> ();

        editingDisplay = new AtavismEditorOption ();
        originalDisplay = new AtavismEditorOption ();
    }
示例#2
0
 public override void CreateNewData()
 {
     editingDisplay = new AtavismEditorOption ();
     originalDisplay = new AtavismEditorOption ();
     selectedDisplay = -1;
 }
示例#3
0
    void LoadOptionChoices(AtavismEditorOption optionData)
    {
        // Read all entries from the table
        string query = "SELECT * FROM " + "editor_option_choice" + " where optionTypeID = " + optionData.id;

        // 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
        if ((rows != null) && (rows.Count > 0)) {
            foreach (Dictionary<string,string> data in rows) {
                AtavismEditorOptionChoice entry = new AtavismEditorOptionChoice ();

                entry.id = int.Parse (data ["id"]);
                entry.choice = data ["choice"];
                optionData.optionChoices.Add (entry);
            }
        }
    }
示例#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
            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;
                    AtavismEditorOption display = new AtavismEditorOption ();
                    display.id = int.Parse (data ["id"]);
                    display.name = data ["optionType"];
                    display.deletable = bool.Parse (data ["deletable"]);

                    display.isLoaded = true;
                    //Debug.Log("Name:" + display.name  + "=[" +  display.id  + "]");
                    dataRegister.Add (display.id, display);
                    displayKeys.Add (display.id);
                }
                LoadSelectList();
            }
            dataLoaded = true;
            foreach (AtavismEditorOption optionData in dataRegister.Values) {
                LoadOptionChoices (optionData);
            }
        }
    }
示例#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 an Option Type before edit it.");
            return;
        }

        // Draw the content database info
        ImagePack.DrawLabel (pos.x, pos.y, "Option Type 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;
        }
    }
示例#6
0
    // Edit or Create
    public override void DrawEditor(Rect box, bool newItem)
    {
        if (!linkedTablesLoaded) {
            linkedTablesLoaded = true;
        }
        // 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
        if (newItem) {
            ImagePack.DrawLabel (pos.x, pos.y, "Create a new Option Type");
            pos.y += ImagePack.fieldHeight;
        }

        editingDisplay.name = ImagePack.DrawField (pos, "Option Type:", editingDisplay.name, 0.5f);
        pos.y += 1.5f * ImagePack.fieldHeight;
        ImagePack.DrawLabel (pos.x, pos.y, "Option Choices");
        pos.y += ImagePack.fieldHeight;

        if (editingDisplay.optionChoices.Count == 0) {
            editingDisplay.optionChoices.Add (new AtavismEditorOptionChoice (0, -1, ""));
        }
        for (int i = 0; i < editingDisplay.optionChoices.Count; i++) {
            pos.width /= 1.5f;
            editingDisplay.optionChoices [i].choice = ImagePack.DrawField (pos, "Choice:", editingDisplay.optionChoices [i].choice);
            pos.x += pos.width;
            if (ImagePack.DrawButton (pos.x, pos.y, "Delete Choice")) {
                if (editingDisplay.optionChoices[i].id > 0)
                    editingDisplay.choicesToBeDeleted.Add(editingDisplay.optionChoices[i].id);
                editingDisplay.optionChoices.RemoveAt(i);
            }
            pos.x -= pos.width;
            pos.width *= 1.5f;
            pos.y += ImagePack.fieldHeight;
        }
        if (ImagePack.DrawButton (pos.x, pos.y, "Add Choice")) {
            editingDisplay.optionChoices.Add (new AtavismEditorOptionChoice (0, -1, ""));
        }

        //pos.width = pos.width * 2;

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

            state = State.Loaded;
        }

        // Delete data
        if (!newItem && editingDisplay.deletable) {
            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);
        }

        EnableScrollBar(pos.y - box.y + 2*ImagePack.fieldHeight);
    }