Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- #####################################################################################################
- # #
- # S.T.A.L.K.E.R. FONT INI FILE RESIZE SCRIPT #
- # #
- # by RENΓ KUHS #
- # #
- #####################################################################################################
- use strict;
- use warnings;
- use Path::Tiny;
- use autodie; # die if problem reading or writing a file
- my $dir = path("H:/Games/S.T.A.L.K.E.R. - Anomaly/tools/_unpacked/textures/ui"); # /INSERT PATH TO FONT INI FILES HERE
- my $file_r = $dir->child("ui_font_letter_25_1600.ini");
- my $file_w = $dir->child("ui_font_letter_25_1600.ini_w");
- # openr_utf8() returns an IO::File object to read from
- # with a UTF-8 decoding layer
- my $file_handle_r = $file_r->openr_utf8();
- # Also open a file for writing
- my $file_handle_w = $file_w->openw_utf8();
- # Indicates whether the following lines are symbol coordinates
- my $contains_coords = 0;
- my $line = "";
- # This while loop checks to see whether this file contains symbol coordinates
- while ( ( $contains_coords == 0 ) && ( $line = $file_handle_r->getline() ) )
- {
- # If the current line contains the appropriate string,
- # we set the appropriate indicator and break the loop
- if ( index( $line, "[symbol_coords]" ) != -1 )
- {
- $contains_coords = 1;
- # Continue retrieving lines until the "height" variable is found
- # (this is usually the very next line, but better safe...)
- $file_handle_w->print( $line );
- while ( ( index( $line, "height =" ) == -1 ) && ( $line = $file_handle_r->getline() ) )
- {
- # If "height" is on current line, quadruple it's value
- if ( index( $line, "height =" ) != -1 )
- {
- my $height = substr( $line, 8 );
- $height *= 2;
- $line = substr( $line, 0, 8 ) . " " . $height . "\n";
- }
- else # No need to write current line to new file here if current line has "height"
- # since that will occur outside of this loop below
- {
- $file_handle_w->print( $line );
- }
- }
- }
- # Write the current line to the new file
- $file_handle_w->print( $line );
- }
- # If the file was previously found to contain symbol coordinates,
- # the rest of the lines in the file are treated as such
- if ( $contains_coords )
- {
- while ( my $line = $file_handle_r->getline() )
- {
- # Split line by comma delimiter
- my @coords = split( ',', substr( $line, 5 ) );
- # Variable which holds the processed line,
- # initialised with first 5 chars of original line
- my $line_proc = substr( $line, 0, 5 );
- foreach my $coord ( @coords )
- {
- # Quadruple coordinate (this removes spaces but no biggie)
- $coord *= 2;
- # Append processed coordinate to line
- $line_proc = $line_proc . " " . $coord . ",";
- }
- # Remove extra comma at end of line
- $line_proc = substr( $line_proc, 0 ,-1 );
- # Write the current line to the new file
- $file_handle_w->print( $line_proc . "\n" );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement