Code:
#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=FoE.ico
#AutoIt3Wrapper_Res_Comment=Made by PatricianS
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_Res_Description=Rome Total War Preferences Editor
#AutoIt3Wrapper_Res_Fileversion=1.0.0.5
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
#AutoIt3Wrapper_Add_Constants=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#Include <WinAPI.au3>
#include <StaticConstants.au3>
#include <Sound.au3>
#include <Array.au3>
; ====================================
;
; By PatricianS
;
; ====================================
Opt('MustDeclareVars', 1)
Opt('GUICloseOnESC', 0)
Global $hGUI
_Question()
Func _Question()
GUICreate ( "Increase unit costs", 260, 20 )
GUISetState()
Global $Factor, $FactorInput = GUICtrlCreateInput ( "", 0, 0, 60, 20 )
Global $Convert = GUICtrlCreateButton( "Caclulate new costs", 60, 0, 200, 20 )
Global $EDUFilePath = "Data\export_descr_unit.txt"
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $Convert
$Factor = GUICtrlRead ( $FactorInput )
_Main()
MsgBox(0, "Info", "A new EDU will be generated on your desktop when done.", 3)
_FileWriteFromArray( @DesktopDir & "\export_descr_unit (costs increased with a factor " & $Factor & ").txt", $EDU, 1 )
; _FileWriteFromArray( $EDUFilePath, $EDU, 1 )
Sleep( 3000 )
MsgBox(0, "Done", "Conversion completed.")
ExitLoop
EndSwitch
WEnd
EndFunc
Func _Main()
Global $EDU[99999]
Global $Matches[99999]
If FileExists ( $EDUFilePath ) Then ; Check for revision number
_FileReadToArray( $EDUFilePath, $EDU )
; _ArrayDisplay( $EDU )
; MsgBox(0, "SRE Result", $CurrentRevision)
For $a = 0 To $EDU[0]
If StringLeft ( $EDU[$a], 9 ) = "stat_cost" Then
;MsgBox(0, "Result", "hit on line: " & $a)
$Matches = StringSplit( $EDU[$a], ",")
;$Matches = StringRegExp( $EDU[$a], "([0-9]{1,9})", 1)
StringTrimLeft ( $Matches[2], 1 ) ; get rid of the additional space.
StringTrimLeft ( $Matches[3], 1 )
StringTrimLeft ( $Matches[4], 1 )
StringTrimLeft ( $Matches[5], 1 )
$Matches[2] = $Matches[2] * $Factor
$Matches[3] = $Matches[3] * $Factor
$Matches[4] = $Matches[4] * $Factor
$Matches[5] = $Matches[5] * $Factor
;_ArrayDisplay( $Matches )
$EDU[$a] = $Matches[1] & ", " & $Matches[2] & ", " & $Matches[3] & ", " & $Matches[4] & ", " & $Matches[5] & "," & $Matches[6]
;_ArrayDisplay( $EDU )
;MsgBox(0, "Result", "The first number is: " & $Matches[2])
;MsgBox(0, "Result", "The second number is: " & $Matches[3])
EndIf
Next
Else
MsgBox(0, "Error", "No EDU found.")
EndIf
EndFunc