Jump to content

Loot Split - First attempt at GUI


Recommended Posts

So I'm working on a script / application to assist people in the gaming world, Usually MMO's, that have lots of loot to be split between players. Specifically I want to make this for Darkfall.

Now before mods get all ban happy this will in no way interact with, or add on to the game. 

I wont be using anything from the game files nor it's allocated memory. 

This will just be simple tool used to save time and calculator buttons.

Script basic process:

What do you have (From a list i'll be making)

how many do you have of them

How many people to split it with

Results (Spits out a table of everyones qty and if it can't be split it's randomly given to one person)

Now On to my current problem, 

I have two list boxes, first to show list of available items to split, Second list shows what items you want to split from that list. Two buttons to add and remove them from the selected list.

I can't figure out how to read all the items from the list.

Here's the code for the entire project:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <ListViewConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>

$DragonLootList = "Gold|Small Map|Medium Map|Large Map|Sele Key|Viel Key|Neithal Key|Leen Key|Theirl Key|"
$SelectedList = ""


#region ### START Koda GUI section ### Form=C:\Documents and Settings\dhicks\My Documents\Scripts\LootSplitter.kxf
$Form1_1 = GUICreate("DF Loot Splitter", 626, 449, 192, 124)
$Tab1 = GUICtrlCreateTab(0, 0, 617, 433)
$TabSheet1 = GUICtrlCreateTabItem("Loot To Split")
GUICtrlSetState(-1, $GUI_SHOW)
$List1 = GUICtrlCreateList("", 4, 25, 209, 396)
GUICtrlSetData(-1, $DragonLootList)
$List2 = GUICtrlCreateList("", 404, 25, 209, 396)
$Add = GUICtrlCreateButton("Add >>", 268, 129, 75, 25)
$Remove = GUICtrlCreateButton("<< Remove", 268, 164, 75, 25)
$Next = GUICtrlCreateButton("Next", 268, 385, 75, 25)
$TabSheet2 = GUICtrlCreateTabItem("How Much")
$ItemList = GUICtrlCreateListView("", 4, 33, 193, 369)
$InputAddTotal = GUICtrlCreateInput("1", 264, 112, 121, 21)
$ButtonAddTotal = GUICtrlCreateButton("Add Total", 287, 136, 75, 25)
GUICtrlSetTip(-1, "How Much of this Item")
$TabSheet3 = GUICtrlCreateTabItem("Results")
$PPLCOUNT = GUICtrlCreateInput("How Many People", 16, 40, 121, 21)
GUICtrlSetTip(-1, "How many people, Whole Numbers only")
$Results = GUICtrlCreateList("", 146, 30, 457, 383)
$Update = GUICtrlCreateButton("Update", 32, 72, 75, 25)
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Form1_1
        Case $List1
        Case $List2
        Case $Add
            $ItemSelected = GUICtrlRead($List1)
            $SelectedList = GUICtrlRead($List2, 1)

            If StringInStr($ItemSelected, $SelectedList) = 0 Then
                GUICtrlSetData($List2, $ItemSelected);& "|" & $SelectedList)

                ConsoleWrite($ItemSelected & " has been added" & @CRLF)
                ConsoleWrite("$SelectedList=" & $SelectedList & @CRLF)
            Else
                ConsoleWrite($ItemSelected & " Is already added" & @CRLF)
            EndIf ; add to selected list

        Case $Remove
        Case $Next
        Case $ButtonAddTotal
        Case $Update
    EndSwitch
    Sleep(10)
WEnd

A true renaissance man

Link to comment
Share on other sites

  • Moderators

Attckdog,

 

Now before mods get all ban happy

As if we would.... :whistle:

As long as this thread remains limited to its current scope I am happy for it to remain open. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Attckdog,

 

As if we would.... :whistle:

As long as this thread remains limited to its current scope I am happy for it to remain open. :)

M23

Yeah, I thought it best to really explain myself thoroughly lol

Any idea on how to pull the entire list text, as a string or even an array?

Thanks!

A true renaissance man

Link to comment
Share on other sites

  • Moderators

Attckdog,

Why bother pulling the list every time - just adjust it as you go along: ;)

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <ListViewConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>

$DragonLootList = "Gold|Small Map|Medium Map|Large Map|Sele Key|Viel Key|Neithal Key|Leen Key|Theirl Key|"
$SelectedList = ""

$Form1_1 = GUICreate("DF Loot Splitter", 626, 449, 192, 124)

$Tab1 = GUICtrlCreateTab(0, 0, 617, 433)

$TabSheet1 = GUICtrlCreateTabItem("Loot To Split")
GUICtrlSetState(-1, $GUI_SHOW)
$List1 = GUICtrlCreateList("", 4, 25, 209, 396)
GUICtrlSetData(-1, $DragonLootList)
$List2 = GUICtrlCreateList("", 404, 25, 209, 396)
$Add = GUICtrlCreateButton("Add >>", 268, 129, 75, 25)
$Remove = GUICtrlCreateButton("<< Remove", 268, 164, 75, 25)
$Next = GUICtrlCreateButton("Next", 268, 385, 75, 25)

$TabSheet2 = GUICtrlCreateTabItem("How Much")
$ItemList = GUICtrlCreateListView("", 4, 33, 193, 369)
$InputAddTotal = GUICtrlCreateInput("1", 264, 112, 121, 21)
$ButtonAddTotal = GUICtrlCreateButton("Add Total", 287, 136, 75, 25)
GUICtrlSetTip(-1, "How Much of this Item")

$TabSheet3 = GUICtrlCreateTabItem("Results")
$PPLCOUNT = GUICtrlCreateInput("How Many People", 16, 40, 121, 21)
GUICtrlSetTip(-1, "How many people, Whole Numbers only")
$Results = GUICtrlCreateList("", 146, 30, 457, 383)
$Update = GUICtrlCreateButton("Update", 32, 72, 75, 25)
GUICtrlCreateTabItem("")

GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Form1_1
        Case $List1
        Case $List2
        Case $Add
            ;Item to be added
            $ItemSelected = GUICtrlRead($List1)
            ; Check if it has already added
            If StringInStr($SelectedList, "|" & $ItemSelected) Then
                ConsoleWrite($ItemSelected & " Is already added" & @CRLF)
            Else
                $SelectedList &= "|" & $ItemSelected
                GUICtrlSetData($List2, $SelectedList)
                ConsoleWrite($ItemSelected & " has been added" & @CRLF)
                ConsoleWrite("$SelectedList = " & $SelectedList & @CRLF)
            EndIf
        Case $Remove
            ;Item to be deleted
            $ItemSelected = GUICtrlRead($List1)
            $SelectedList = StringReplace($SelectedList, "|" & $ItemSelected, "")
            GUICtrlSetData($List2, $SelectedList)
            ConsoleWrite($ItemSelected & " has been deleted" & @CRLF)
            ConsoleWrite("$SelectedList = " & $SelectedList & @CRLF)
        Case $Next
        Case $ButtonAddTotal
        Case $Update
    EndSwitch

    ;Sleep(10) ; No need as GUIGetMsg has a built-in Sleep

WEnd
M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

If you do need to dump the listbox to a string or array, you would just count the items with _GUICtrlListBox_GetCount() and loop through the items pulling the text with _GUICtrlListBox_GetText().

Something like this would work for you:

Func _GetListItems($hLB, $iType = 0, $sDelim = '|')
    ;$hLV = Handle of ListBox
    ;$iType 0 = String
    ;$iType 1 = Array
    ;$sDelim = delimiter (Only used for $iType 0)

    Local $iCount = _GUICtrlListBox_GetCount($hLB)
    Local $aRet[1] = [$iCount], $sRet = '', $sItem
    If $iCount = 0 Then
        If $iType = 0 Then Return SetError(1, 0, $sRet)
        If $iType = 1 Then Return SetError(1, 0, $aRet)
    EndIf
    If $iType = 1 Then ReDim $aRet[$iCount + 1]
    For $i = 0 To $iCount - 1
        $sItem = _GUICtrlListBox_GetText($hLB, $i)
        If $iType = 0 Then $sRet &= $sItem
        If $iType = 1 Then $aRet[$i + 1] = $sItem
        If $iType = 0 And $i <> $iCount - 1 Then $sRet &= $sDelim
    Next
    If $iType = 0 Then Return $sRet
    If $iType = 1 Then Return $aRet
EndFunc
Link to comment
Share on other sites

Attckdog,

Why bother pulling the list every time - just adjust it as you go along: ;)

M23

 

Awesome, I've copied you code exactly, I've found an odd effect though. When removing items from $selectedList you can only remove an item after attempting to add one. I'm going to be attempting to fix this in the mean time.

Edit: Found the problem and fixed it. it was using the same var for both list selected item. So it was pulling selected item from the first list not the second. Adjusted it now it works how I imagined. I'll likely be back with more problems later.

 

If you do need to dump the listbox to a string or array, you would just count the items with _GUICtrlListBox_GetCount() and loop through the items pulling the text with _GUICtrlListBox_GetText().

Something like this would work for you:

 

I'll likely use this, I'll make sure to include you in the the credits. TY

Edit: Danwilli - I'm not getting expected results from the function, it is returning 0 no matter what I do. I'll play around with it and see if I can get something to work. Will post update. 

Edit2: Got it working, I was using the wrong var for the list box. Duh...

Edited by Attckdog

A true renaissance man

Link to comment
Share on other sites

New Problem, I can't figure out how to add / update the items in a listview with more than 1 column. 

I'd like to be able to select and update the qty of an item. Any ideas?

Edit: Figured it out ! 

 
Edited by Attckdog

A true renaissance man

Link to comment
Share on other sites

Just an update on my progress so far. 

Ran into quite a few new things I've never worked with so progress has been slow. Not to mention it's a side project for giggles you know how that goes.

Anyways here's my current code as of now. I got everything working up to getting qty for each item. I'm pretty sure I know how I'll do that so it's just a matter of writing it out. 

Code: 

Edited by Attckdog

A true renaissance man

Link to comment
Share on other sites

Alright Got much farther along. ran into a new problem though. I'm not sure how I'm going to hand the Random Rolls for non splitable items.

For instacne, You got a group of 2 ppl and 1 leen key drops. I'd like the script to randomly select who gets it and post the results. I'm not sure how I would make that work.

Code:

#cs
    
    Dragon Loot Splitter Script.
    Later it will grow to Include all DFUW loot.
    By David Hicks, 2013
    
    Notice  -   Darkfall and all the names and stuff that are prolly copyrighted belong to whoever.
    wont be making any money off this script so please do not sue me thx
    
    -----------------------------------------------------------------------
    CopyRight 2013 David Hicks
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    -----------------------------------------------------------------------
#ce
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>

;I'm going to change the item list to be saved in a text file.
$DragonLootList = "Gold|Small Map|Medium Map|Large Map|Sele Key|Viel Key|Neithal Key|Leen Key|Theirl Key|"
$SelectedList = ""
Global $SelectedItemsList[1], $qty[1], $ItemQtyListArray[1], $Result[1], $everyGetsResults[1]



#region ### START Koda GUI section ### Form=C:\Documents and Settings\dhicks\My Documents\Scripts\LootSplitter.kxf
$Form1_1 = GUICreate("DF Loot Splitter", 627, 450, 192, 124)
$Tab1 = GUICtrlCreateTab(0, 0, 617, 433)
$TabSheet1 = GUICtrlCreateTabItem("Loot To Split")
GUICtrlSetState(-1, $GUI_SHOW)
$List1 = GUICtrlCreateList("", 4, 26, 209, 384)
GUICtrlSetData(-1, $DragonLootList)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$List2 = GUICtrlCreateList("", 404, 26, 209, 384)
GUICtrlSetData(-1, "")
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Add = GUICtrlCreateButton("Add >>", 268, 130, 75, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Remove = GUICtrlCreateButton("<< Remove", 268, 165, 75, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Next = GUICtrlCreateButton("Next", 280, 386, 75, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Group1 = GUICtrlCreateGroup("Info / Messages", 216, 233, 185, 105)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Label1 = GUICtrlCreateLabel("Welcome!" & @CRLF & "Please Select Items to Split from the left List.", 224, 249, 170, 76)
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
GUICtrlCreateGroup("", -99, -99, 1, 1)

$TabSheet2 = GUICtrlCreateTabItem("How Much")
$ItemList = GUICtrlCreateListView("Item|Amount", 4, 34, 193, 369)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 120)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 75)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$InputAddTotal = GUICtrlCreateInput("", 264, 113, 121, 22)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$ButtonAddTotal = GUICtrlCreateButton("Add Total", 287, 137, 75, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetTip(-1, "How Much of this Item")
$Next2 = GUICtrlCreateButton("Next", 280, 387, 75, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetTip(-1, "Save and Move to Next Step")

$TabSheet3 = GUICtrlCreateTabItem("Results")
$PPLCOUNT = GUICtrlCreateInput("2", 16, 41, 121, 22)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetTip(-1, "How many people, Whole Numbers only")
$Update = GUICtrlCreateButton("Update", 160, 41, 75, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$ListView1 = GUICtrlCreateListView("Item|Amount", 12, 97, 281, 328)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 120)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 75)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Everyone = GUICtrlCreateLabel("Everyone Gets:", 104, 72, 79, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Label2 = GUICtrlCreateLabel("Randomly distrubted", 408, 72, 102, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$ListView2 = GUICtrlCreateListView("", 320, 96, 282, 326)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###


While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Form1_1
        Case $List1
        Case $List2
        Case $Add
            ;Item to be added - Needs to be changed to remove the item that's added from List1
            $ItemSelected = GUICtrlRead($List1)
            ; Check if it has already added
            If StringInStr($SelectedList, "|" & $ItemSelected) Then
                ConsoleWrite($ItemSelected & " Is already added" & @CRLF)
                GUICtrlSetData($Label1, $ItemSelected & " Is already added")
            Else
                $SelectedList &= "|" & $ItemSelected
                GUICtrlSetData($List2, $SelectedList)
                ConsoleWrite($ItemSelected & " has been added" & @CRLF)
                ConsoleWrite("$SelectedList = " & $SelectedList & @CRLF)
            EndIf

        Case $Remove
            ;Item to be deleted
            ConsoleWrite("Remove button Pressed" & @CRLF)
            ConsoleWrite("Bfore $SelectedList = " & $SelectedList & @CRLF)
            $ItemSelected2 = GUICtrlRead($List2)
            If $ItemSelected2 = "" Then
                GUICtrlSetData($Label1, "Please Select an Item from list to remove.")
            Else
                $SelectedList = StringReplace($SelectedList, "|" & $ItemSelected2, "")

                GUICtrlSetData($List2, $SelectedList)
                ConsoleWrite($ItemSelected2 & " has been deleted" & @CRLF)
                ConsoleWrite("after $SelectedList = " & $SelectedList & @CRLF)
            EndIf
        Case $Next ; save lists for next page, move to next page
            ConsoleWrite("Next button Pressed, Saving SelectedItemList to memory" & @CRLF)
            $getListCount = _GUICtrlListBox_GetCount($List2) - 1
            $SelectedItemsList[0] = _GUICtrlListBox_GetText($List2, 0)
            $qty[0] = 0
            For $count = 1 To $getListCount
                ConsoleWrite("ListCount = " & $count & "/" & $getListCount & @CRLF)
                _ArrayAdd($SelectedItemsList, _GUICtrlListBox_GetText($List2, $count))
                _ArrayAdd($qty, 0)
            Next
            ;_ArrayDisplay($SelectedItemsList)
            ;_ArrayDisplay($qty)

            ConsoleWrite("SelectedItemList = " & _ArrayToString($SelectedItemsList) & @CRLF)
            ConsoleWrite("|" & _ArrayToString($SelectedItemsList) & @CRLF)
            For $count2 = 0 To $getListCount
                _GUICtrlListView_AddItem($ItemList, $SelectedItemsList[$count2])
                _GUICtrlListView_AddSubItem($ItemList, $count2, $qty[$count2], 1)
            Next
            GUICtrlSetState($TabSheet2, $GUI_SHOW)
        Case $ButtonAddTotal
            $ItemQtyToChange = _GUICtrlListView_GetSelectedIndices($ItemList)
            $QtyToAdd = GUICtrlRead($InputAddTotal)
            GUICtrlSetData($InputAddTotal, "")
            _GUICtrlListView_SetItemText($ItemList, $ItemQtyToChange, $QtyToAdd, 1)

        Case $Next2 ; gather item qty save it to memory
            $ItemListCount = _GUICtrlListView_GetItemCount($ItemList)
            For $x = 1 To $ItemListCount
                ConsoleWrite("$ItemListCount = " & $x & "/" & $ItemListCount & @CRLF)
                _ArrayAdd($ItemQtyListArray, _GUICtrlListView_GetItemText($ItemList, $x - 1, 1))
                If @error Then
                    ConsoleWrite("Error: " & @error & @CRLF)
                EndIf
            Next
            _ArrayDelete($ItemQtyListArray, 0)
            ;_ArrayDisplay($ItemQtyListArray)
            GUICtrlSetState($TabSheet3, $GUI_SHOW)
            ConsoleWrite(_ArrayToString($ItemQtyListArray) & @CRLF)

        Case $Update ; get # of ppl Then do the math  then display it
            $go = False
            $PPLToAdd = GUICtrlRead($PPLCOUNT)
            $PPLToAdd = $PPLToAdd + 0 ; to make sure it's treated as a number

            If IsNumber($PPLToAdd) = 1 Then
                If IsFloat($PPLToAdd) = 0 Then
                    ;Valid Input Accept and process
                    GUICtrlSetData($PPLCOUNT, $PPLToAdd)
                    $go = True
                Else
                    ToolTip('Not A Whole number Please enter whole numbers only. no text or ","')
                    ; Not valid input ignore and warn
                EndIf
            Else
                ; Not A number Please enter whole numbers only no text or ","
                ToolTip('Not A number Please enter whole numbers only. no text or ","')
            EndIf

            If $go = True Then
                ConsoleWrite("-Starting Math-" & @CRLF)
                _ArrayDisplay($SelectedItemsList) ; names
                _ArrayDisplay($ItemQtyListArray) ; qtys
                ;$PPLToAdd is total players


                For $y = 0 To $ItemListCount - 1
                    ConsoleWrite("Starting Item: " & $y & "/" & $ItemListCount & @CRLF)
                    $Rollit = False
                    $test = $ItemQtyListArray[$y] / $PPLToAdd
                    If IsFloat($test) = 1 Then
                        $Rollit = True
                        $LoopTest = $ItemQtyListArray[$y]
                        $ContinueMath = 1
                        While $ContinueMath = 1 ; Loop until whole number split
                            $Difference = $Difference + 1
                            $LoopTest = $LoopTest - 1
                            If $LoopTest <= 0 Then
                                $test = $LoopTest
                                $ContinueMath = 0
                            Else
                                If IsFloat($LoopTest) = 1 Then
                                    ConsoleWrite($LoopTest & @CRLF)
                                Else
                                    ConsoleWrite("Found Non-Float! " & $LoopTest & @CRLF)
                                    $test = $LoopTest
                                    $ContinueMath = 0
                                EndIf
                            EndIf
                        WEnd
                    Else ; first test results = not float
                        ConsoleWrite("Found Non-Float! " & $test & @CRLF)
                    EndIf

                    _ArrayAdd($everyGetsResults, $test)
                    If $Rollit = True Then
                    EndIf


                Next

                ConsoleWrite("-Math Done-" & @CRLF)
                _ArrayDelete($everyGetsResults, 0)
                _ArrayDisplay($everyGetsResults)

                ; populate Lists
                For $z = 0 To $ItemListCount - 1
                    ConsoleWrite("Everyone's Results list = " & $SelectedItemsList[$z] & " - " & $everyGetsResults[$z] & @CRLF)
                    _GUICtrlListView_AddItem($ListView1, $SelectedItemsList[$z])
                    _GUICtrlListView_AddSubItem($ListView1, $z, $everyGetsResults[$z], 1)
                Next


            Else ; go
            EndIf ; go


    EndSwitch
WEnd
Edited by Attckdog

A true renaissance man

Link to comment
Share on other sites

FYI, I got a warning when running your script.  Line 211 of your script says "$Difference = $Difference + 1", and $Difference doesn't show up anywhere else.  Either you forgot to use it, or you forgot to remove it.

Anyway, randomly choosing a person is easy.  You can use something like:

$LuckyPerson = Random(0, $PartySize - 1, 1)

Where $PartySize is the total number of people questing together and $LuckyPerson is a 0-based index number.  You could enter the player names into an array ahead of time, and use $LuckyPerson to reference the winner's name.

 

Also, I don't know if this is expected behavior at this point, but I completely missed the Next button on my first test.  I used the Tabs to navigate instead.  The loot drops didn't populate into the second tab.  I moved to the 3rd tab and hit the Update button (to try to get things to populate), and an output window showed up, empty.  I dismissed it, and it popped up again.  When I closed it the second time, the script crashed.  Yes, that's absolutely user error, but I wanted to mention it in case people other than you will be using the script.

Edited by Artisan
Link to comment
Share on other sites

FYI, I got a warning when running your script.  Line 211 of your script says "$Difference = $Difference + 1", and $Difference doesn't show up anywhere else.  Either you forgot to use it, or you forgot to remove it.

Anyway, randomly choosing a person is easy.  You can use something like:

$LuckyPerson = Random(0, $PartySize - 1, 1)

Where $PartySize is the total number of people questing together and $LuckyPerson is a 0-based index number.  You could enter the player names into an array ahead of time, and use $LuckyPerson to reference the winner's name.

 

Also, I don't know if this is expected behavior at this point, but I completely missed the Next button on my first test.  I used the Tabs to navigate instead.  The loot drops didn't populate into the second tab.  I moved to the 3rd tab and hit the Update button (to try to get things to populate), and an output window showed up, empty.  I dismissed it, and it popped up again.  When I closed it the second time, the script crashed.  Yes, that's absolutely user error, but I wanted to mention it in case people other than you will be using the script.

 

Yeah that "$Difference"was extra code I forgot to remove before posting. I was using it to toy around with a few ideas. 

I'm using random and getting the correct output but now I'm having problems getting everything to display how I'd like it. I suppose i just need to play around with it some more.

The Tabs for navigating is a problem and will be fixed I just want to get a working prototype before I refine it too much. I got a lot of different ideas for it. Like an output to clipboard button and things like that to make it easy to share with people in game. Export to Text. Stuff like that. Way more Items, Maybe an extra tab that stores expected drops for certain mobs so you can just choose a mob you've farmed and it would automatically fill the item selector portation with expect drops. 

 

EDIT: I think I'm just going to write the whole thing again and simplify the code and keep a proper Variable naming convention. This shit is nearly unreadable.

First things first! I'd like to get the math together and actually display it in a way I like. 

Here's my latest code. Once again it's sloppy and ugly but that's to be expected right?

#cs
    
    Dragon Loot Splitter Script.
    Later it will grow to Include all DFUW loot.
    By David Hicks, 2013
    
    Notice  -   Darkfall and all the names and stuff that are prolly copyrighted belong to whoever.
    wont be making any money off this script so please do not sue me thx
    
    -----------------------------------------------------------------------
    CopyRight 2013 David Hicks
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    -----------------------------------------------------------------------
#ce
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>

$DragonLootList = "Gold|Small Map|Medium Map|Large Map|Sele Key|Viel Key|Neithal Key|Leen Key|Theirl Key|"
$SelectedList = ""
Global $SelectedItemsList[1], $qty[1], $ItemQtyListArray[1], $Result[1], $everyGetsResults[1]



#region ### START Koda GUI section ### Form=C:\Documents and Settings\dhicks\My Documents\Scripts\LootSplitter.kxf
$Form1_1 = GUICreate("DF Loot Splitter", 627, 450, 192, 124)
$Tab1 = GUICtrlCreateTab(0, 0, 617, 433)
$TabSheet1 = GUICtrlCreateTabItem("Loot To Split")
GUICtrlSetState(-1, $GUI_SHOW)
$List1 = GUICtrlCreateList("", 4, 26, 209, 384)
GUICtrlSetData(-1, $DragonLootList)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$List2 = GUICtrlCreateList("", 404, 26, 209, 384)
GUICtrlSetData(-1, "")
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Add = GUICtrlCreateButton("Add >>", 268, 130, 75, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Remove = GUICtrlCreateButton("<< Remove", 268, 165, 75, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Next = GUICtrlCreateButton("Next", 280, 386, 75, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Group1 = GUICtrlCreateGroup("Info / Messages", 216, 233, 185, 105)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Label1 = GUICtrlCreateLabel("Welcome!" & @CRLF & "Please Select Items to Split from the left List.", 224, 249, 170, 76)
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
GUICtrlCreateGroup("", -99, -99, 1, 1)

$TabSheet2 = GUICtrlCreateTabItem("How Much")
$ItemList = GUICtrlCreateListView("Item|Amount", 4, 34, 193, 369)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 120)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 75)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$InputAddTotal = GUICtrlCreateInput("", 264, 113, 121, 22)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$ButtonAddTotal = GUICtrlCreateButton("Add Total", 287, 137, 75, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetTip(-1, "How Much of this Item")
$Next2 = GUICtrlCreateButton("Next", 280, 387, 75, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetTip(-1, "Save and Move to Next Step")

$TabSheet3 = GUICtrlCreateTabItem("Results")
$PPLCOUNT = GUICtrlCreateInput("2", 16, 41, 121, 22)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetTip(-1, "How many people, Whole Numbers only")
$Update = GUICtrlCreateButton("Update", 160, 41, 75, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$ListView1 = GUICtrlCreateListView("Item|Amount", 12, 97, 281, 328)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 120)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 75)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Everyone = GUICtrlCreateLabel("Everyone Gets:", 104, 72, 79, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Label2 = GUICtrlCreateLabel("Randomly distrubted", 408, 72, 102, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$ListView2 = GUICtrlCreateListView("Item|Amount|Player", 320, 96, 282, 326)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 75)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 120)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 75)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###


While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Form1_1
        Case $List1
        Case $List2
        Case $Add
            ;Item to be added - Needs to be changed to remove the item that's added from List1
            $ItemSelected = GUICtrlRead($List1)
            ; Check if it has already added
            If StringInStr($SelectedList, "|" & $ItemSelected) Then
                ConsoleWrite($ItemSelected & " Is already added" & @CRLF)
                GUICtrlSetData($Label1, $ItemSelected & " Is already added")
            Else
                $SelectedList &= "|" & $ItemSelected
                GUICtrlSetData($List2, $SelectedList)
                ConsoleWrite($ItemSelected & " has been added" & @CRLF)
                ConsoleWrite("$SelectedList = " & $SelectedList & @CRLF)
            EndIf

        Case $Remove
            ;Item to be deleted
            ConsoleWrite("Remove button Pressed" & @CRLF)
            ConsoleWrite("Bfore $SelectedList = " & $SelectedList & @CRLF)
            $ItemSelected2 = GUICtrlRead($List2)
            If $ItemSelected2 = "" Then
                GUICtrlSetData($Label1, "Please Select an Item from list to remove.")
            Else
                $SelectedList = StringReplace($SelectedList, "|" & $ItemSelected2, "")

                GUICtrlSetData($List2, $SelectedList)
                ConsoleWrite($ItemSelected2 & " has been deleted" & @CRLF)
                ConsoleWrite("after $SelectedList = " & $SelectedList & @CRLF)
            EndIf
        Case $Next ; save lists for next page, move to next page
            ConsoleWrite("Next button Pressed, Saving SelectedItemList to memory" & @CRLF)
            $getListCount = _GUICtrlListBox_GetCount($List2) - 1
            $SelectedItemsList[0] = _GUICtrlListBox_GetText($List2, 0)
            $qty[0] = 0
            For $count = 1 To $getListCount
                ConsoleWrite("ListCount = " & $count & "/" & $getListCount & @CRLF)
                _ArrayAdd($SelectedItemsList, _GUICtrlListBox_GetText($List2, $count))
                _ArrayAdd($qty, 0)
            Next
            ;_ArrayDisplay($SelectedItemsList)
            ;_ArrayDisplay($qty)

            ConsoleWrite("SelectedItemList = " & _ArrayToString($SelectedItemsList) & @CRLF)
            ConsoleWrite("|" & _ArrayToString($SelectedItemsList) & @CRLF)
            For $count2 = 0 To $getListCount
                _GUICtrlListView_AddItem($ItemList, $SelectedItemsList[$count2])
                _GUICtrlListView_AddSubItem($ItemList, $count2, $qty[$count2], 1)
            Next
            GUICtrlSetState($TabSheet2, $GUI_SHOW)
        Case $ButtonAddTotal
            $ItemQtyToChange = _GUICtrlListView_GetSelectedIndices($ItemList)
            $QtyToAdd = GUICtrlRead($InputAddTotal)
            GUICtrlSetData($InputAddTotal, "")
            _GUICtrlListView_SetItemText($ItemList, $ItemQtyToChange, $QtyToAdd, 1)

        Case $Next2 ; gather item qty save it to memory
            $ItemListCount = _GUICtrlListView_GetItemCount($ItemList)
            For $x = 1 To $ItemListCount
                ConsoleWrite("$ItemListCount = " & $x & "/" & $ItemListCount & @CRLF)
                _ArrayAdd($ItemQtyListArray, _GUICtrlListView_GetItemText($ItemList, $x - 1, 1))
                If @error Then
                    ConsoleWrite("Error: " & @error & @CRLF)
                EndIf
            Next
            _ArrayDelete($ItemQtyListArray, 0)
            ;_ArrayDisplay($ItemQtyListArray)
            GUICtrlSetState($TabSheet3, $GUI_SHOW)
            ConsoleWrite(_ArrayToString($ItemQtyListArray) & @CRLF)

        Case $Update ; get # of ppl Then do the math  then display it
            $go = False
            $PPLToAdd = GUICtrlRead($PPLCOUNT)
            $PPLToAdd = $PPLToAdd + 0 ; to make sure it's treated as a number

            If IsNumber($PPLToAdd) = 1 Then
                If IsFloat($PPLToAdd) = 0 Then
                    ;Valid Input Accept and process
                    GUICtrlSetData($PPLCOUNT, $PPLToAdd)
                    $go = True
                Else
                    ToolTip('Not A Whole number Please enter whole numbers only. no text or ","')
                    ; Not valid input ignore and warn
                EndIf
            Else
                ; Not A number Please enter whole numbers only no text or ","
                ToolTip('Not A number Please enter whole numbers only. no text or ","')
            EndIf

            If $go = True Then
                ConsoleWrite("-Starting Math-" & @CRLF)
                _ArrayDisplay($SelectedItemsList) ; names
                _ArrayDisplay($ItemQtyListArray) ; qtys
                ;$PPLToAdd is total players


                For $y = 0 To $ItemListCount - 1
                    ConsoleWrite("Starting Item: " & $y & "/" & $ItemListCount & @CRLF)
                    $Rollit = False
                    $Difference = 0
                    $test = $ItemQtyListArray[$y] / $PPLToAdd
                    If IsFloat($test) = 1 Then
                        $Rollit = True
                        $LoopTest = $ItemQtyListArray[$y]
                        $ContinueMath = 1
                        While $ContinueMath = 1 ; Loop until whole number split
                            $Difference = $Difference + 1
                            $LoopTest = $LoopTest - 1
                            If $LoopTest <= 0 Then
                                $test = $LoopTest
                                $ContinueMath = 0
                            Else
                                If IsFloat($LoopTest) = 1 Then
                                    ConsoleWrite($LoopTest & @CRLF)
                                Else
                                    ConsoleWrite("Found Non-Float! " & $LoopTest & @CRLF)
                                    $test = $LoopTest
                                    $ContinueMath = 0
                                EndIf
                            EndIf
                        WEnd
                    Else ; first test results = not float
                        ConsoleWrite("Found Non-Float! " & $test & @CRLF)
                        $Rollit = False
                    EndIf

                    _ArrayAdd($everyGetsResults, $test)
                    If $Rollit = True Then
                        $Roll = Random(1, $PPLToAdd, 1)
                        _GUICtrlListView_AddItem($ListView2, $SelectedItemsList[$y])
                        _GUICtrlListView_AddSubItem($ListView2, $y, $Difference, 1)
                        _GUICtrlListView_AddSubItem($ListView2, $y, "Player " & $Roll, 2)
                        ConsoleWrite("Player " & $Roll & " won " & $Difference & " Of " & $SelectedItemsList[$y] & @CRLF)
                    EndIf
                Next

                ConsoleWrite("-Math Done-" & @CRLF)
                _ArrayDelete($everyGetsResults, 0)
                _ArrayDisplay($everyGetsResults)

                ; populate Lists
                For $z = 0 To $ItemListCount - 1
                    ConsoleWrite("Everyone's Results list = " & $SelectedItemsList[$z] & " - " & $everyGetsResults[$z] & @CRLF)
                    _GUICtrlListView_AddItem($ListView1, $SelectedItemsList[$z])
                    _GUICtrlListView_AddSubItem($ListView1, $z, $everyGetsResults[$z], 1)
                Next


            Else ; go
            EndIf ; go


    EndSwitch
WEnd
Edited by Attckdog

A true renaissance man

Link to comment
Share on other sites

So to help make moving forward easier I rewrote the entire script. I'm extremely happy I did too.

The code is much cleaner and has legible variable names not to mention performs more like I'd like it to.

I'm still not entirely sure how I'm going to distribute the items and display them. But I'm working on it.
Here's the code so far: 

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>

$DragonLootList = "Gold|Small Map|Medium Map|Large Map|Sele Key|Viel Key|Neithal Key|Leen Key|Theirl Key|"
;Loot Lists will eventually be pulled from a text file
$SelectedList = ""
Local $List2ItemCountArraySize = 1
Local $List2ItemCountArrayData[$List2ItemCountArraySize][2]
;;;;;; Not if I'll use these
;Local $PlayerLootArraySize = 1
;Local $PlayerLootArrayData[$PlayerLootArraySize][
;;;;;;

#region ### START Koda GUI section ### Form=C:\Documents and Settings\dhicks\My Documents\Scripts\LootSplitter.kxf
$Form1_1 = GUICreate("DF Loot Splitter", 627, 450, 192, 124)
$Tab1 = GUICtrlCreateTab(0, 0, 617, 433)
$TabSheet1 = GUICtrlCreateTabItem("Loot To Split")
GUICtrlSetState(-1, $GUI_SHOW)
$List1 = GUICtrlCreateList("", 4, 26, 209, 384)
GUICtrlSetData(-1, $DragonLootList)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")

$List2 = GUICtrlCreateList("", 404, 26, 209, 384)
GUICtrlSetData(-1, "")
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Add = GUICtrlCreateButton("Add >>", 268, 130, 75, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Remove = GUICtrlCreateButton("<< Remove", 268, 165, 75, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Next = GUICtrlCreateButton("Next", 280, 386, 75, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Group1 = GUICtrlCreateGroup("Info / Messages", 216, 233, 185, 105)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Label1 = GUICtrlCreateLabel("Welcome!" & @CRLF & "Please Select Items to Split from the left List.", 224, 249, 170, 76)
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
GUICtrlCreateGroup("", -99, -99, 1, 1)

$TabSheet2 = GUICtrlCreateTabItem("How Much")
$ItemList = GUICtrlCreateListView("Item|Amount", 4, 34, 193, 369)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 120)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 75)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$InputAddTotal = GUICtrlCreateInput("", 264, 113, 121, 22)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$ButtonAddTotal = GUICtrlCreateButton("Add Total", 287, 137, 75, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetTip(-1, "How Much of this Item")
$Next2 = GUICtrlCreateButton("Next", 280, 387, 75, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetTip(-1, "Save and Move to Next Step")

$TabSheet3 = GUICtrlCreateTabItem("Results")
$PPLCOUNT = GUICtrlCreateInput("2", 16, 41, 121, 22)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlSetTip(-1, "How many people, Whole Numbers only")
$Update = GUICtrlCreateButton("Update", 160, 41, 75, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$ListView1 = GUICtrlCreateListView("Item|Amount", 12, 97, 281, 328)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 120)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 75)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Everyone = GUICtrlCreateLabel("Everyone Gets:", 104, 72, 79, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Label2 = GUICtrlCreateLabel("Randomly distrubted", 408, 72, 102, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$ListView2 = GUICtrlCreateListView("Item|Amount|Player", 320, 96, 282, 326)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 75)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 120)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 75)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
_GUICtrlListBox_SetCurSel($List1, 0)
_GUICtrlListBox_SetCurSel($List2, 0)
#endregion ### END Koda GUI section ###
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
            ;-----------------------------------------------------------------------------------------
        Case $Add ;
            ConsoleWrite("Add button Pressed" & @CRLF)
            $List1CurrentlySelectIndex = _GUICtrlListBox_GetCurSel($List1)
            If $List1CurrentlySelectIndex = -1 Then
                ConsoleWrite("Add button Pressed but nothing selected" & @CRLF)
                _GUICtrlListBox_SetCurSel($List1, 0)
            Else ; Add/remove whatever is selected
                $List1CurrentlySelectTxt = _GUICtrlListBox_GetText($List1, $List1CurrentlySelectIndex)
                _GUICtrlListBox_AddString($List2, $List1CurrentlySelectTxt)
                _GUICtrlListBox_DeleteString($List1, $List1CurrentlySelectIndex)
                ConsoleWrite($List1CurrentlySelectTxt & " Was Added to List2" & @CRLF)
                _GUICtrlListBox_SetCurSel($List1, 0)
                _GUICtrlListBox_SetCurSel($List2, 0)
            EndIf
            ;-----------------------------------------------------------------------------------------
        Case $Remove
            ConsoleWrite("$Remove Pressed" & @CRLF)
            $List2CurrentlySelectIndex = _GUICtrlListBox_GetCurSel($List2)
            If $List2CurrentlySelectIndex = -1 Then
                ConsoleWrite("Remove button Pressed but nothing selected" & @CRLF)
                _GUICtrlListBox_SetCurSel($List2, 0)
            Else ; Add/remove whatever is selected
                $List2CurrentlySelectTxt = _GUICtrlListBox_GetText($List2, $List2CurrentlySelectIndex)
                _GUICtrlListBox_AddString($List1, $List2CurrentlySelectTxt)
                _GUICtrlListBox_DeleteString($List2, $List2CurrentlySelectIndex)
                ConsoleWrite($List2CurrentlySelectTxt & " Was Added to List1" & @CRLF)
                _GUICtrlListBox_SetCurSel($List1, 0)
                _GUICtrlListBox_SetCurSel($List2, 0)
            EndIf
            ;-----------------------------------------------------------------------------------------
        Case $Next ; save lists for next page, move to next page
            ConsoleWrite("Next button Pressed" & @CRLF)
            $List2ItemCountArraySize = _GUICtrlListBox_GetCount($List2)
            If IsArray($List2ItemCountArrayData) Then
                If UBound($List2ItemCountArrayData, 1) < $List2ItemCountArraySize Then
                    ReDim $List2ItemCountArrayData[$List2ItemCountArraySize][2]
                EndIf
            EndIf
            For $x = 0 To $List2ItemCountArraySize - 1
                $List2ItemCountArrayData[$x][0] = _GUICtrlListBox_GetText($List2, $x)
                $List2ItemCountArrayData[$x][1] = 1
            Next
            ;_ArrayDisplay($List2ItemCountArrayData)
            ConsoleWrite("Showing TabSheet2" & @CRLF)
            _GUICtrlListView_AddArray($ItemList, $List2ItemCountArrayData)
            GUICtrlSetState($TabSheet2, $GUI_SHOW)
            _GUICtrlListView_SetItemSelected($ItemList, 0)
            GUICtrlSetState($InputAddTotal, $GUI_FOCUS)
        Case $TabSheet2 ; Same As first next button
            ;-----------------------------------------------------------------------------------------
        Case $InputAddTotal
            ConsoleWrite("InputAddTotal EnterKey Pressed" & @CRLF)
            $InputAddTotalNumber = GUICtrlRead($InputAddTotal)
            $ItemListSelectedIndices = _GUICtrlListView_GetSelectedIndices($ItemList)
            $ItemListItemCount = _GUICtrlListView_GetItemCount($ItemList)
            _GUICtrlListView_SetItemText($ItemList, $ItemListSelectedIndices, $InputAddTotalNumber, 1)
            $List2ItemCountArrayData[$ItemListSelectedIndices][1] = $InputAddTotalNumber
            If $ItemListSelectedIndices + 1 > $ItemListItemCount Then
                ConsoleWrite("Reached End of ItemList" & @CRLF)
            Else
                _GUICtrlListView_SetItemSelected($ItemList, $ItemListSelectedIndices + 1)
                GUICtrlSetState($InputAddTotal, $GUI_FOCUS)
            EndIf
            ConsoleWrite($List2ItemCountArrayData[$ItemListSelectedIndices][1] & @CRLF)
            ;-----------------------------------------------------------------------------------------
        Case $ButtonAddTotal
            ConsoleWrite("ButtonAddToal Pressed" & @CRLF)
            $InputAddTotalNumber = GUICtrlRead($InputAddTotal)
            $ItemListSelectedIndices = _GUICtrlListView_GetSelectedIndices($ItemList)
            $ItemListItemCount = _GUICtrlListView_GetItemCount($ItemList)
            _GUICtrlListView_SetItemText($ItemList, $ItemListSelectedIndices, $InputAddTotalNumber, 1)
            $List2ItemCountArrayData[$ItemListSelectedIndices][1] = $InputAddTotalNumber
            If $ItemListSelectedIndices + 1 > $ItemListItemCount Then
                ConsoleWrite("Reached End of ItemList" & @CRLF)
            Else
                _GUICtrlListView_SetItemSelected($ItemList, $ItemListSelectedIndices + 1)
                GUICtrlSetState($InputAddTotal, $GUI_FOCUS)
            EndIf
            ConsoleWrite($List2ItemCountArrayData[$ItemListSelectedIndices][1] & @CRLF)
            ;-----------------------------------------------------------------------------------------
        Case $Next2 ; gather item qty save it to memory
            ;_ArrayDisplay($List2ItemCountArrayData)
            GUICtrlSetState($TabSheet3, $GUI_SHOW)
            GUICtrlSetState($PPLCOUNT, $GUI_FOCUS)
            ;-----------------------------------------------------------------------------------------
        Case $TabSheet3 ; Same as Next2
            ;-----------------------------------------------------------------------------------------
        Case $PPLCOUNT ;get # of ppl Then do the math  then display it Same as Update BUtton press
            ConsoleWrite("PPLCOUNT EnterKey Pressed" & @CRLF)
            $PPLCOUNTNumber = GUICtrlRead($PPLCOUNT)
            GUICtrlSetState($PPLCOUNT, $GUI_FOCUS)

            For $M = 0 To $List2ItemCountArraySize - 1
                $MathFloatTest = $List2ItemCountArrayData[$M][1] / $PPLCOUNTNumber
                If IsFloat($MathFloatTest) Then
                    ConsoleWrite("Item Is a Float: " & $MathFloatTest & @CRLF)

                    While $ContinueMath = 1 ; Loop until whole number split
                        $Difference = $Difference + 1
                        $LoopTest = $LoopTest - 1
                        If $LoopTest <= 0 Then
                            $test = $LoopTest
                            $ContinueMath = 0
                        Else
                            If IsFloat($LoopTest) = 1 Then
                                ;Continue Float testing
                            Else
                                ConsoleWrite("Found Non-Float! " & $LoopTest & @CRLF)
                                $MathFloatTest = $LoopTest
                                $ContinueMath = 0
                            EndIf
                        EndIf
                    WEnd
                    ;Roll Fuction stuff Goes Here
                Else
                    ConsoleWrite("Item Is NOT a Float: " & $MathFloatTest & @CRLF)
                EndIf; Float Test
            Next ; for each Each Item

            ;Output What everyone got
            ;Coloums = ItemName, ItemQty
            ;Output all the playerLootResults into A ListViewBox Grouped by Player?
            ;Coloums = Player, ItemName, ItemQty

            ;-----------------------------------------------------------------------------------------
        Case $Update ; ;get # of ppl Then do the math  then display it Same as Hitting enter inside PPLCOUNT INput BOx
            ;-----------------------------------------------------------------------------------------
    EndSwitch
WEnd
;-----------------------------------------------------------------------------------------
;           Functions
;-----------------------------------------------------------------------------------------

Func _RollForIt($ItemAmount, $NumberOfWays, $Mode = 1)

    ;$ItemAmount = the number of items to split
    ;$NumberOfWays = The Number of people to split it With
    ;;;
    ;If Mode 1 is on then Items are split in bulk, IE if 4 items are the remainder then those 4 items go to one person
    ;If Mode 2 i on then items are split more evenly by Assigning Random Distribution for how many items IE:
    ; - If there are 2 items to split out and 5 members it will roll for each person and highest and second highest get 1 item.
    If $Mode = 1 Then
    EndIf
    If $Mode = 2 Then
    Else
        ConsoleWrite("_RollForIt Error: Not Acceptable Mode" & @CRLF)
    EndIf
EndFunc   ;==>_RollForIt

A true renaissance man

Link to comment
Share on other sites

Lines 185, 186, 187 - you use variables without initializing them ($ContinueMath, $Difference, $LoopTest).  You should have something like "$ContinueMath = 1" before the first time to test it.  Yes it runs, but it's poor practice to test a variable's value before you've ever assigned anything to it.

As for how to display everything, consider using a multi-column ListView.  Each player can have a column stating what they get, and it will automatically have scroll bars if needed to be able to see everything.  Another option is to use a single-column List Box.  For each player, you add to the list box their name, loot list, and a blank row.  Either approach would fit with your current design for the 3rd tab.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...