PB-IDE Opensource developer helper tools

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
User avatar
mk-soft
Always Here
Always Here
Posts: 5313
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

PB-IDE Opensource developer helper tools

Post by mk-soft »

Convert the exported colours from the PB-IDE into DataSection code.

Code: Select all

;-TOP

; Comment : Convert exported IDE Colors to PB-Code for Preferences.pb
; Author  : mk-soft
; Version : v1.01.0
;
; Insert to DataSection DefaultColorSchemes:
; First value is total number of defined schemes 

Global NewList Colors.s()
Global file.s

Procedure LoadColorPref(FileName.s, Schema.s)
  Protected keyName.s, keyValue.s, comment.s
  Protected temp.s, red.s, green.s, blue.s
  
  If OpenPreferences(FileName)
    PreferenceGroup("Colors")
    ExaminePreferenceKeys()
    While NextPreferenceKey()
      keyName = PreferenceKeyName()
      keyValue = PreferenceKeyValue()
      If Not FindString(keyName, "_Used")
        keyValue = RemoveString(keyValue, "RGB(")
        keyValue = RemoveString(keyValue, ")")
        keyValue = RemoveString(keyValue, " ")
        red = RSet(Hex(Val(StringField(keyValue, 1, ","))), 2, "0")
        green = RSet(Hex(Val(StringField(keyValue, 2, ","))), 2, "0")
        blue = RSet(Hex(Val(StringField(keyValue, 3, ","))), 2, "0")
        If Not FindString(keyName, "ToolsPanel")
          comment = RemoveString(keyName, "_") 
          comment = RemoveString(comment, "Color")
          comment = " ; #COLOR_" + comment
        Else
          comment = " ;  " + keyName
        EndIf
        temp = "  Data.l $" + blue + green + red + comment
        AddElement(Colors())
        Colors() = temp
      EndIf
    Wend
    LastElement(Colors())
    MoveElement(Colors(), #PB_List_First)
    FirstElement(Colors())
    LastElement(Colors())
    MoveElement(Colors(), #PB_List_First)
    FirstElement(Colors())
    InsertElement(Colors())
    Colors() = "  Data$ " + #DQUOTE$ + Schema + #DQUOTE$
  EndIf
  
EndProcedure

file = OpenFileRequester("PB Color Preferences", "", "", 0)
If file
  LoadColorPref(file, "Dark Mode")
  ForEach Colors()
    Debug Colors()
  Next
EndIf
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5342
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: PB-IDE Opensource developer helper tools

Post by Kwai chang caine »

Works nice
Thanks for sharing 8)
ImageThe happiness is a road...
Not a destination
Post Reply