Exemplo n.º 1
0
    def do_conversion(self):
        if not self.source_directory.get():
            tkinter.messagebox.showerror("Input directory not selected",
                                         "Input directory not selected",
                                         parent=self)

        elif not self.target_directory.get():
            tkinter.messagebox.showerror("Error: Output directory not selected",
                                         "Output directory not selected",
                                         parent=self)

        else:
            logging.info("source-directory: %s", self.source_directory.get())
            logging.info("target-directory: %s", self.target_directory.get())

            cfg = rfactortools.rFactorToGSC2013Config()

            cfg.unique_team_names = self.unique_team_names.get()
            cfg.force_track_thumbnails = self.force_track_thumb.get()
            cfg.clear_classes = self.clear_classes.get()
            cfg.single_gamedata = self.single_gamedata.get()
            cfg.fix_light_intensity = self.fix_light_intensity.get()
            cfg.copy_missing_textures = self.copy_missing_textures.get()

            if self.vehicle_category.get().strip():
                cfg.vehicle_category = self.vehicle_category.get().strip()

            if self.track_category.get().strip():
                cfg.track_category = self.track_category.get().strip()

            cfg.reiza_class = self.reiza_class.get().strip()

            cfg.track_filter_properties = self.track_filter_properties.get().strip()

            self.app.start_conversion(self.source_directory.get(), self.target_directory.get(), cfg)
Exemplo n.º 2
0
    def test_loading_aspect(self):
        """Test that the aspect ratio of the loading screen is properly converted

        This test gives a "ResourceWarning: unclosed file" warning, see:
        https://github.com/python-imaging/Pillow/issues/477
        """

        input_directory = os.path.join(self.test_datadir, "loading_aspect/GameData/")
        output_directory = os.path.join(self.tmpdir, "loading_aspect")

        cfg = rfactortools.rFactorToGSC2013Config()
        converter = rfactortools.rFactorToGSC2013(input_directory, cfg)
        converter.convert_all(output_directory)

        # check that images that aren't 800x600 or 1024x768 are resized properly
        img = Image.open(os.path.join(output_directory,
                                      "GameData/Locations/TestTrack/TestTrack_loading.jpg"))
        self.assertEqual(img.size, (1024, 768))

        # check that images that already are 800x600 or 1024x768 stay untouched
        self.assertTrue(filecmp.cmp(os.path.join(input_directory,
                                                 "Locations/TestTrack2/TestTrack2_loading.jpg"),
                                    os.path.join(output_directory,
                                                 "GameData/Locations/TestTrack2/TestTrack2_loading.jpg")))

        self.assertTrue(filecmp.cmp(os.path.join(input_directory,
                                                 "Locations/TestTrack3/TestTrack3_loading.jpg"),
                                    os.path.join(output_directory,
                                                 "GameData/Locations/TestTrack3/TestTrack3_loading.jpg")))
Exemplo n.º 3
0
    def test_cmaps_dontfix(self):
        """Make sure that MASFile=cmaps.mas is not fixed when the cmaps is in another mod directory"""

        input_directory = os.path.join(self.test_datadir, "cmaps_dontfix/GameData/")
        output_directory = os.path.join(self.tmpdir, "cmap_dontfix")

        cfg = rfactortools.rFactorToGSC2013Config()
        converter = rfactortools.rFactorToGSC2013(input_directory, cfg)
        converter.convert_all(output_directory)

        with rfactortools.open_read(os.path.join(output_directory,
                                                 "GameData/Vehicles/TheMod/Subdir/graphics.gen")) as fin:
            self.assertEqual(fin.read(),
                             "MASFile=cmaps.mas\n")
Exemplo n.º 4
0
    def test_cmaps_dontfix(self):
        """Make sure that MASFile=cmaps.mas is not fixed when the cmaps is in another mod directory"""

        input_directory = os.path.join(self.test_datadir,
                                       "cmaps_dontfix/GameData/")
        output_directory = os.path.join(self.tmpdir, "cmap_dontfix")

        cfg = rfactortools.rFactorToGSC2013Config()
        converter = rfactortools.rFactorToGSC2013(input_directory, cfg)
        converter.convert_all(output_directory)

        with rfactortools.open_read(
                os.path.join(
                    output_directory,
                    "GameData/Vehicles/TheMod/Subdir/graphics.gen")) as fin:
            self.assertEqual(fin.read(), "MASFile=cmaps.mas\n")
Exemplo n.º 5
0
    def do_conversion(self):
        if not self.source_directory.get():
            tkinter.messagebox.showerror("Input directory not selected",
                                         "Input directory not selected",
                                         parent=self)

        elif not self.target_directory.get():
            tkinter.messagebox.showerror(
                "Error: Output directory not selected",
                "Output directory not selected",
                parent=self)

        else:
            logging.info("source-directory: %s", self.source_directory.get())
            logging.info("target-directory: %s", self.target_directory.get())

            cfg = rfactortools.rFactorToGSC2013Config()

            cfg.unique_team_names = self.unique_team_names.get()
            cfg.force_track_thumbnails = self.force_track_thumb.get()
            cfg.clear_classes = self.clear_classes.get()
            cfg.single_gamedata = self.single_gamedata.get()
            cfg.fix_light_intensity = self.fix_light_intensity.get()
            cfg.copy_missing_textures = self.copy_missing_textures.get()

            if self.vehicle_category.get().strip():
                cfg.vehicle_category = self.vehicle_category.get().strip()

            if self.track_category.get().strip():
                cfg.track_category = self.track_category.get().strip()

            cfg.reiza_class = self.reiza_class.get().strip()

            cfg.track_filter_properties = self.track_filter_properties.get(
            ).strip()

            self.app.start_conversion(self.source_directory.get(),
                                      self.target_directory.get(), cfg)
Exemplo n.º 6
0
    def test_loading_aspect(self):
        """Test that the aspect ratio of the loading screen is properly converted

        This test gives a "ResourceWarning: unclosed file" warning, see:
        https://github.com/python-imaging/Pillow/issues/477
        """

        input_directory = os.path.join(self.test_datadir,
                                       "loading_aspect/GameData/")
        output_directory = os.path.join(self.tmpdir, "loading_aspect")

        cfg = rfactortools.rFactorToGSC2013Config()
        converter = rfactortools.rFactorToGSC2013(input_directory, cfg)
        converter.convert_all(output_directory)

        # check that images that aren't 800x600 or 1024x768 are resized properly
        img = Image.open(
            os.path.join(output_directory,
                         "GameData/Locations/TestTrack/TestTrack_loading.jpg"))
        self.assertEqual(img.size, (1024, 768))

        # check that images that already are 800x600 or 1024x768 stay untouched
        self.assertTrue(
            filecmp.cmp(
                os.path.join(input_directory,
                             "Locations/TestTrack2/TestTrack2_loading.jpg"),
                os.path.join(
                    output_directory,
                    "GameData/Locations/TestTrack2/TestTrack2_loading.jpg")))

        self.assertTrue(
            filecmp.cmp(
                os.path.join(input_directory,
                             "Locations/TestTrack3/TestTrack3_loading.jpg"),
                os.path.join(
                    output_directory,
                    "GameData/Locations/TestTrack3/TestTrack3_loading.jpg")))
Exemplo n.º 7
0
# 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/>.


import argparse
import logging
import sys

import rfactortools


if __name__ == "__main__":
    cfg = rfactortools.rFactorToGSC2013Config()

    parser = argparse.ArgumentParser(description='rFactor to GSC2013 converter')
    parser.add_argument('DIRECTORY', action='store', type=str, nargs='+',
                        help='directory containing the mod')
    parser.add_argument('-o', '--output', metavar='DIR', type=str,
                        help="output directory")
    parser.add_argument('-i', '--info', action='store_true', default=False,
                        help="show info on the mod")
    parser.add_argument('-v', '--verbose', action='store_true', default=False,
                        help="be more verbose")
    parser.add_argument('-q', '--quiet', action='store_true', default=False,
                        help="be less verbose")
    args = parser.parse_args()

    target_directory = args.output
Exemplo n.º 8
0
# 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/>.

import argparse
import logging
import sys

import rfactortools

if __name__ == "__main__":
    cfg = rfactortools.rFactorToGSC2013Config()

    parser = argparse.ArgumentParser(
        description='rFactor to GSC2013 converter')
    parser.add_argument('DIRECTORY',
                        action='store',
                        type=str,
                        nargs='+',
                        help='directory containing the mod')
    parser.add_argument('-o',
                        '--output',
                        metavar='DIR',
                        type=str,
                        help="output directory")
    parser.add_argument('-i',
                        '--info',
Exemplo n.º 9
0
    def createWidgets(self):
        self.grid_columnconfigure(1, weight=1)
        self.grid_columnconfigure(0, weight=0)
        self.grid_rowconfigure(0, weight=1)

        self.photo = PIL.ImageTk.PhotoImage(PIL.Image.open("logo.png"))
        self.photo_label = tk.Label(self,
                                    image=self.photo,
                                    anchor=N,
                                    width=256,
                                    height=256)
        self.photo_label["bg"] = "black"
        self.photo_label.grid(column=0, row=0, sticky=N + S + W + E)
        self.photo_label.winfo_height = 256

        self.scrollbar = tk.Scrollbar(self)
        self.scrollbar.grid(column=2, row=0, sticky=N + S)

        self.text = tk.Text(self, yscrollcommand=self.scrollbar.set)
        self.text.insert(tk.END, welcome_text)
        self.text.config(state=tk.DISABLED)
        self.text.grid(column=1, row=0, sticky=N + S + W + E)
        self.scrollbar.config(command=self.text.yview)

        self.directory_frame = tk.Frame(self)
        self.directory_frame.grid_columnconfigure(1, weight=1)
        self.source_directory = createDirectoryEntry(self.directory_frame,
                                                     "Input:", 0)
        self.target_directory = createDirectoryEntry(self.directory_frame,
                                                     "Output:", 1)
        self.target_directory.set("build/")
        self.directory_frame.grid(column=0,
                                  row=1,
                                  columnspan=3,
                                  sticky=W + E,
                                  padx=8,
                                  pady=4)

        # Options
        self.option_frame = tk.LabelFrame(self, text="Options", padx=8, pady=4)
        self.option_frame.grid(column=0,
                               row=2,
                               columnspan=3,
                               sticky=N + S + W + E,
                               padx=8,
                               pady=4)
        self.option_frame.grid_columnconfigure(1, minsize=200)

        defaults = rfactortools.rFactorToGSC2013Config()

        self.unique_team_names = tk.BooleanVar(
            value=defaults.unique_team_names)
        self.unique_team_names_checkbox = tk.Checkbutton(
            self.option_frame,
            text="Unique Team Names",
            variable=self.unique_team_names)
        self.unique_team_names_checkbox.grid(column=0,
                                             row=0,
                                             columnspan=2,
                                             sticky=W)

        self.force_track_thumb = tk.BooleanVar(
            value=defaults.force_track_thumbnails)
        self.force_track_thumb_checkbox = tk.Checkbutton(
            self.option_frame,
            text="Force Track Thumbnail",
            variable=self.force_track_thumb)
        self.force_track_thumb_checkbox.grid(column=0,
                                             row=1,
                                             columnspan=2,
                                             sticky=W)

        self.clear_classes = tk.BooleanVar(value=defaults.clear_classes)
        self.clear_classes_checkbox = tk.Checkbutton(
            self.option_frame,
            text="Clear Vehicle Classes",
            variable=self.clear_classes)
        self.clear_classes_checkbox.grid(column=0,
                                         row=2,
                                         columnspan=2,
                                         sticky=W)

        self.single_gamedata = tk.BooleanVar(value=defaults.single_gamedata)
        self.single_gamedata_checkbox = tk.Checkbutton(
            self.option_frame,
            text="Single GameData/ Output",
            variable=self.single_gamedata)
        self.single_gamedata_checkbox.grid(column=0,
                                           row=3,
                                           columnspan=2,
                                           sticky=W)

        self.fix_light_intensity = tk.BooleanVar(
            value=defaults.fix_light_intensity)
        self.fix_light_intensity_checkbox = tk.Checkbutton(
            self.option_frame,
            text="Fix Light Intensity",
            variable=self.fix_light_intensity)
        self.fix_light_intensity_checkbox.grid(column=0,
                                               row=4,
                                               columnspan=2,
                                               sticky=W)

        self.copy_missing_textures = tk.BooleanVar(
            value=defaults.copy_missing_textures)
        self.copy_missing_textures_checkbox = tk.Checkbutton(
            self.option_frame,
            text="Copy Missing Textures",
            variable=self.copy_missing_textures)
        self.copy_missing_textures_checkbox.grid(column=0,
                                                 row=5,
                                                 columnspan=2,
                                                 sticky=W)

        self.vehicle_category = tk.StringVar(value=defaults.vehicle_category)
        self.vehicle_category_label = tk.Label(self.option_frame,
                                               text="Vehicle Category:")
        self.vehicle_category_label.grid(column=2, row=0, sticky=E)
        self.vehicle_category_entry = tk.Entry(
            self.option_frame, textvariable=self.vehicle_category)
        self.vehicle_category_entry.grid(column=3, row=0, sticky=W)

        self.track_category = tk.StringVar(value=defaults.track_category)
        self.track_category_label = tk.Label(self.option_frame,
                                             text="Track Category:")
        self.track_category_label.grid(column=2, row=1, sticky=E)
        self.track_category_entry = tk.Entry(self.option_frame,
                                             textvariable=self.track_category)
        self.track_category_entry.grid(column=3, row=1, sticky=W)

        self.reiza_class = tk.StringVar(value=defaults.reiza_class)
        self.reiza_class_label = tk.Label(self.option_frame,
                                          text="Reiza Class:")
        self.reiza_class_label.grid(column=2, row=2, sticky=E)
        self.reiza_class_entry = tk.Entry(self.option_frame,
                                          textvariable=self.reiza_class)
        self.reiza_class_entry.grid(column=3, row=2, sticky=W)

        self.track_filter_properties = tk.StringVar(
            value=defaults.track_filter_properties)
        self.track_filter_properties_label = tk.Label(
            self.option_frame, text="Track Filter Properties:")
        self.track_filter_properties_label.grid(column=2, row=3, sticky=E)
        self.track_filter_properties_entry = tk.Entry(
            self.option_frame, textvariable=self.track_filter_properties)
        self.track_filter_properties_entry.grid(column=3, row=3, sticky=W)

        # Buttons
        self.button_frame = tk.Frame(self)
        self.button_frame.grid(column=0,
                               row=3,
                               columnspan=3,
                               sticky=W + E + N + S)

        self.confirm_button_frame = tk.Frame(self.button_frame)
        self.confirm_button_frame.pack(side=tk.RIGHT)

        self.tool_button_frame = tk.Frame(self.button_frame)
        self.tool_button_frame.pack(side=tk.LEFT)

        self.vehtree_btn = tk.Button(self.tool_button_frame)
        self.vehtree_btn["text"] = ".veh tree"
        self.vehtree_btn["command"] = self.do_veh_tree
        self.vehtree_btn.grid(column=0, row=0, sticky=S, pady=8, padx=8)

        self.veh_btn = tk.Button(self.tool_button_frame)
        self.veh_btn["text"] = ".veh check"
        self.veh_btn["command"] = self.do_veh_check
        self.veh_btn.grid(column=1, row=0, sticky=S, pady=8, padx=8)

        self.gen_btn = tk.Button(self.tool_button_frame)
        self.gen_btn["text"] = ".gen check"
        self.gen_btn["command"] = self.do_gen_check
        self.gen_btn.grid(column=2, row=0, sticky=S, pady=8, padx=8)

        self.cancel_btn = tk.Button(self.confirm_button_frame)
        self.cancel_btn["text"] = "Quit"
        self.cancel_btn["command"] = self.quit
        self.cancel_btn.grid(column=3, row=0, sticky=S, pady=8, padx=8)

        self.convert_btn = tk.Button(self.confirm_button_frame)
        self.convert_btn["text"] = "Convert"
        self.convert_btn["command"] = self.do_conversion
        self.convert_btn.grid(column=4, row=0, sticky=S, pady=8, padx=8)
Exemplo n.º 10
0
    def createWidgets(self):
        self.grid_columnconfigure(1, weight=1)
        self.grid_columnconfigure(0, weight=0)
        self.grid_rowconfigure(0, weight=1)

        self.photo = PIL.ImageTk.PhotoImage(PIL.Image.open("logo.png"))
        self.photo_label = tk.Label(self, image=self.photo, anchor=N, width=256, height=256)
        self.photo_label["bg"] = "black"
        self.photo_label.grid(column=0, row=0, sticky=N+S+W+E)
        self.photo_label.winfo_height = 256

        self.scrollbar = tk.Scrollbar(self)
        self.scrollbar.grid(column=2, row=0, sticky=N+S)

        self.text = tk.Text(self, yscrollcommand=self.scrollbar.set)
        self.text.insert(tk.END, welcome_text)
        self.text.config(state=tk.DISABLED)
        self.text.grid(column=1, row=0, sticky=N+S+W+E)
        self.scrollbar.config(command=self.text.yview)

        self.directory_frame = tk.Frame(self)
        self.directory_frame.grid_columnconfigure(1, weight=1)
        self.source_directory = createDirectoryEntry(self.directory_frame, "Input:", 0)
        self.target_directory = createDirectoryEntry(self.directory_frame, "Output:", 1)
        self.target_directory.set("build/")
        self.directory_frame.grid(column=0, row=1, columnspan=3, sticky=W+E, padx=8, pady=4)

        # Options
        self.option_frame = tk.LabelFrame(self, text="Options", padx=8, pady=4)
        self.option_frame.grid(column=0, row=2, columnspan=3, sticky=N+S+W+E, padx=8, pady=4)
        self.option_frame.grid_columnconfigure(1, minsize=200)

        defaults = rfactortools.rFactorToGSC2013Config()

        self.unique_team_names = tk.BooleanVar(value=defaults.unique_team_names)
        self.unique_team_names_checkbox = tk.Checkbutton(self.option_frame, text="Unique Team Names",
                                                         variable=self.unique_team_names)
        self.unique_team_names_checkbox.grid(column=0, row=0, columnspan=2, sticky=W)

        self.force_track_thumb = tk.BooleanVar(value=defaults.force_track_thumbnails)
        self.force_track_thumb_checkbox = tk.Checkbutton(self.option_frame, text="Force Track Thumbnail",
                                                         variable=self.force_track_thumb)
        self.force_track_thumb_checkbox.grid(column=0, row=1, columnspan=2, sticky=W)

        self.clear_classes = tk.BooleanVar(value=defaults.clear_classes)
        self.clear_classes_checkbox = tk.Checkbutton(self.option_frame, text="Clear Vehicle Classes",
                                                     variable=self.clear_classes)
        self.clear_classes_checkbox.grid(column=0, row=2, columnspan=2, sticky=W)

        self.single_gamedata = tk.BooleanVar(value=defaults.single_gamedata)
        self.single_gamedata_checkbox = tk.Checkbutton(self.option_frame, text="Single GameData/ Output",
                                                       variable=self.single_gamedata)
        self.single_gamedata_checkbox.grid(column=0, row=3, columnspan=2, sticky=W)

        self.fix_light_intensity = tk.BooleanVar(value=defaults.fix_light_intensity)
        self.fix_light_intensity_checkbox = tk.Checkbutton(self.option_frame, text="Fix Light Intensity",
                                                           variable=self.fix_light_intensity)
        self.fix_light_intensity_checkbox.grid(column=0, row=4, columnspan=2, sticky=W)

        self.copy_missing_textures = tk.BooleanVar(value=defaults.copy_missing_textures)
        self.copy_missing_textures_checkbox = tk.Checkbutton(self.option_frame, text="Copy Missing Textures",
                                                             variable=self.copy_missing_textures)
        self.copy_missing_textures_checkbox.grid(column=0, row=5, columnspan=2, sticky=W)

        self.vehicle_category = tk.StringVar(value=defaults.vehicle_category)
        self.vehicle_category_label = tk.Label(self.option_frame, text="Vehicle Category:")
        self.vehicle_category_label.grid(column=2, row=0, sticky=E)
        self.vehicle_category_entry = tk.Entry(self.option_frame, textvariable=self.vehicle_category)
        self.vehicle_category_entry.grid(column=3, row=0, sticky=W)

        self.track_category = tk.StringVar(value=defaults.track_category)
        self.track_category_label = tk.Label(self.option_frame, text="Track Category:")
        self.track_category_label.grid(column=2, row=1, sticky=E)
        self.track_category_entry = tk.Entry(self.option_frame, textvariable=self.track_category)
        self.track_category_entry.grid(column=3, row=1, sticky=W)

        self.reiza_class = tk.StringVar(value=defaults.reiza_class)
        self.reiza_class_label = tk.Label(self.option_frame, text="Reiza Class:")
        self.reiza_class_label.grid(column=2, row=2, sticky=E)
        self.reiza_class_entry = tk.Entry(self.option_frame, textvariable=self.reiza_class)
        self.reiza_class_entry.grid(column=3, row=2, sticky=W)

        self.track_filter_properties = tk.StringVar(value=defaults.track_filter_properties)
        self.track_filter_properties_label = tk.Label(self.option_frame, text="Track Filter Properties:")
        self.track_filter_properties_label.grid(column=2, row=3, sticky=E)
        self.track_filter_properties_entry = tk.Entry(self.option_frame, textvariable=self.track_filter_properties)
        self.track_filter_properties_entry.grid(column=3, row=3, sticky=W)

        # Buttons
        self.button_frame = tk.Frame(self)
        self.button_frame.grid(column=0, row=3, columnspan=3, sticky=W+E+N+S)

        self.confirm_button_frame = tk.Frame(self.button_frame)
        self.confirm_button_frame.pack(side=tk.RIGHT)

        self.tool_button_frame = tk.Frame(self.button_frame)
        self.tool_button_frame.pack(side=tk.LEFT)

        self.vehtree_btn = tk.Button(self.tool_button_frame)
        self.vehtree_btn["text"] = ".veh tree"
        self.vehtree_btn["command"] = self.do_veh_tree
        self.vehtree_btn.grid(column=0, row=0, sticky=S, pady=8, padx=8)

        self.veh_btn = tk.Button(self.tool_button_frame)
        self.veh_btn["text"] = ".veh check"
        self.veh_btn["command"] = self.do_veh_check
        self.veh_btn.grid(column=1, row=0, sticky=S, pady=8, padx=8)

        self.gen_btn = tk.Button(self.tool_button_frame)
        self.gen_btn["text"] = ".gen check"
        self.gen_btn["command"] = self.do_gen_check
        self.gen_btn.grid(column=2, row=0, sticky=S, pady=8, padx=8)

        self.cancel_btn = tk.Button(self.confirm_button_frame)
        self.cancel_btn["text"] = "Quit"
        self.cancel_btn["command"] = self.quit
        self.cancel_btn.grid(column=3, row=0, sticky=S, pady=8, padx=8)

        self.convert_btn = tk.Button(self.confirm_button_frame)
        self.convert_btn["text"] = "Convert"
        self.convert_btn["command"] = self.do_conversion
        self.convert_btn.grid(column=4, row=0, sticky=S, pady=8, padx=8)