Autor Beitrag
mtin
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 177

Win XP SP2
BDS2006 Enterprise
BeitragVerfasst: Sa 07.05.05 10:26 
I'm trying to put together a little game loader...
now I'm stuck at making a checkbox to run Battlefield Vietnam in a Window...
I've got if checkbox.checked=true then ....
But it's kinda hard to get bfv into window mode: you have to edit the file

C:\Programme\EA GAMES\Battlefield Vietnam\Mods\BfVietnam\settings\VideoDefault.con

and change the line renderer.FullScreen 1 to renderer.FullScreen 0
And if the checkbox is not checked it should edit the file again and set it back to renderer.FullScreen 1(else ....)

how could I do this?

(the VideoDefault.con looks like this:)
Zitat:

rem * TEMP *
renderer.FullScreen 1
console.showStats 0
renderer.allowAllRefreshRates 0
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Sa 07.05.05 12:12 
You could load the file into a TStringList, which then allows you to access every single line of the file. Then you can iterate through the lines and search for the String "renderer.FullScreen" (f.i. with pos()). Depending on the checkbox value, you can then overwrite this line in the StringList either with "renderer.FullScreen 1" or "renderer.FullScreen 0". Then, simply write the StringList to the file, overwriting previous information (but you just changed this single line) and start the game.

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
mtin Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 177

Win XP SP2
BDS2006 Enterprise
BeitragVerfasst: Sa 07.05.05 12:25 
arg ich weiß auch nich warum ich grad englisch gepostet hab :roll:
(tut mir leid, normalerweise muss ich immer englisch schreiben :lol: )

also da ich noch mehr oder weniger SEHR neu bin könntest du das vielleicht noch nen bischen genauer erklären?
wär sehr nett!!!
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Sa 07.05.05 12:38 
user profile iconmtin hat folgendes geschrieben:
arg ich weiß auch nich warum ich grad englisch gepostet hab :roll:
Hihi, kenne ich ;-)

TStringList hat die Methode LoadFromFile(), die eine Textdatei zeilenweise in die Stringlist lädt. Anschließend kannst du mit dem Porperty Strings auf jeden einzelnen String zugreifen, wobei jeder String in der Liste einer Zeile entspricht. Du gehst also alle Strings durch und suchst nach dem Vorkommen von "renderer.FullScreen". Du merkst dir also den Index des Strings und ersetzt den String an dieser Stelle in der Liste mit "renderer.FullScreen 1" oder "renderer.FullScreen 0", abhängig davon, ob die Checkbox markiert ist, oder nicht.
Einfach mal in der Onlinehilfe nach TStringlist suchen, da dürften Beispiele für alle Methoden und Eigenschaften dabei sein, die du benötigst.

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
mtin Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 177

Win XP SP2
BDS2006 Enterprise
BeitragVerfasst: Sa 07.05.05 13:50 
habs jetzt einigermaßen hinbekommen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
if CheckBox7.checked=true then
  begin
  bf:=ExtractFilePath(bfv)+'Mods\BfVietnam\settings\VideoDefault.con';
  SL := TStringList.Create;
  SL.LoadFromFile(bf);
  Sl.Strings[1]:='renderer.FullScreen 0';
  SL.SaveToFile(bf);
  SL.Free;
  speichern('config','bf_window','true');
  end;
if CheckBox7.checked=false then
  begin
  bf:=ExtractFilePath(bfv)+'Mods\BfVietnam\settings\VideoDefault.con';
  SL := TStringList.Create;
  SL.LoadFromFile(bf);
  Sl.Strings[1]:='renderer.FullScreen 1';
  SL.SaveToFile(bf);
  SL.Free;
  speichern('config','bf_window','false');
  end;


funktioniert zwar, is aber natürlich ganz schön viel code um einfach mal im fenstermodus zu starten :/
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Sa 07.05.05 13:59 
Da es viel redundanten Code gibt, kannst du es weiter verkürzen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
bf:=ExtractFilePath(bfv)+'Mods\BfVietnam\settings\VideoDefault.con';
SL := TStringList.Create;
SL.LoadFromFile(bf);
if CheckBox7.checked=true then
begin
  Sl.Strings[1]:='renderer.FullScreen 0';
  speichern('config','bf_window','true');
end
else if CheckBox7.checked=false then
begin
  Sl.Strings[1]:='renderer.FullScreen 1';
  speichern('config','bf_window','false');
end;
SL.SaveToFile(bf);
SL.Free;
Aber weißt du denn zuverlässig, daß renderer.FullScreen immer in der zweiten Zeile steht? Du greifst nämlichnur auf Strings[1] zu. Kommt es nie vor, daß es mal in der ersten oder in der dritten Zeile steht? Deswegen meinte ich noch, es wäre besser du gehst alle Zeilen durch und schaust, in welcher "renderer.FullScreen" vorkommt.

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
mtin Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 177

Win XP SP2
BDS2006 Enterprise
BeitragVerfasst: Sa 07.05.05 14:06 
also eigentlich steht das immer in der 2. Zeile, außer wenn jemand per Hand in seinen config-Dateien rumspielt.... :wink:

trotzdem danke für deine Hilfe!
mtin Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 177

Win XP SP2
BDS2006 Enterprise
BeitragVerfasst: Do 12.05.05 16:40 
hm... also jetzt geht das doch nur auf meinem Rechner, anscheinend steht das doch manchmal in anderen Zeilen...
könnte mir jemand an nem beispiel das suchen nach einer zeile mit bestimmten Inhalt in ner TStringList erklären?

ich gebs ja zu ich bin zu faul mir nen tutorial zu suchen :oops: