<commit_before>﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.EventSystems;
using UnityEngine.Events;

public class PuzzleImageWindow
{
    public EventManager.Event eventData;
    QuestData.Puzzle questPuzzle;
    public PuzzleImage puzzle;
    public int previousMoves = 0;
    public Sprite[][] imageSprite;
    public float width = 1f;
    public float height = 1f;

    public PuzzleImageWindow(EventManager.Event e)
    {
        eventData = e;
        Game game = Game.Get();

        questPuzzle = e.qEvent as QuestData.Puzzle;

        if (game.quest.puzzle.ContainsKey(questPuzzle.name))
        {
            puzzle = game.quest.puzzle[questPuzzle.name] as PuzzleImage;
            previousMoves = puzzle.moves;
        }
        else
        {
            puzzle = new PuzzleImage(questPuzzle.puzzleLevel, questPuzzle.puzzleAltLevel);
        }

        height = 19f / questPuzzle.puzzleAltLevel;
        width = 19f / questPuzzle.puzzleLevel;
        Texture2D newTex = ContentData.FileToTexture(game.cd.puzzles[questPuzzle.imageType].image);
        if (newTex.width > newTex.height)
        {
            height = height * newTex.height / newTex.width;
        }
        else
        {
            width = width * newTex.width / newTex.height;
        }

        imageSprite = new Sprite[questPuzzle.puzzleLevel][];
        for (int i = 0; i < questPuzzle.puzzleLevel; i++)
        {
            imageSprite[i] = new Sprite[questPuzzle.puzzleAltLevel];
            for (int j = 0; j < questPuzzle.puzzleAltLevel; j++)
            {
                imageSprite[i][j] = Sprite.Create(newTex, new Rect(i * newTex.width / questPuzzle.puzzleLevel, (questPuzzle.puzzleAltLevel - (j + 1)) * newTex.height / questPuzzle.puzzleAltLevel, newTex.width / questPuzzle.puzzleLevel, newTex.height / questPuzzle.puzzleAltLevel), Vector2.zero, 1);
            }
        }

        CreateWindow();<commit_msg>Support for custom image puzzles.<commit_after>﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.EventSystems;
using UnityEngine.Events;

public class PuzzleImageWindow
{
    public EventManager.Event eventData;
    QuestData.Puzzle questPuzzle;
    public PuzzleImage puzzle;
    public int previousMoves = 0;
    public Sprite[][] imageSprite;
    public float width = 1f;
    public float height = 1f;

    public PuzzleImageWindow(EventManager.Event e)
    {
        eventData = e;
        Game game = Game.Get();

        questPuzzle = e.qEvent as QuestData.Puzzle;

        if (game.quest.puzzle.ContainsKey(questPuzzle.name))
        {
            puzzle = game.quest.puzzle[questPuzzle.name] as PuzzleImage;
            previousMoves = puzzle.moves;
        }
        else
        {
            puzzle = new PuzzleImage(questPuzzle.puzzleLevel, questPuzzle.puzzleAltLevel);
        }

        height = 19f / questPuzzle.puzzleAltLevel;
        width = 19f / questPuzzle.puzzleLevel;

        Texture2D newTex = null;
        if (game.cd.puzzles.ContainsKey(questPuzzle.imageType))
        {
            newTex = ContentData.FileToTexture(game.cd.puzzles[questPuzzle.imageType].image);
        }
        else
        {
            newTex = ContentData.FileToTexture(System.IO.Path.GetDirectoryName(game.quest.qd.questPath) + "/" + questPuzzle.imageType);
        }
        if (newTex.width > newTex.height)
        {
            height = height * newTex.height / newTex.width;
        }
        else
        {
            width = width * newTex.width / newTex.height;
        }

        imageSprite = new Sprite[questPuzzle.puzzleLevel][];
        for (int i = 0; i < questPuzzle.puzzleLevel; i++)
        {
            imageSprite[i] = new Sprite[questPuzzle.puzzleAltLevel];
            for (int j = 0; j < questPuzzle.puzzleAltLevel; j++)
            {
                imageSprite[i][j] = Sprite.Create(newTex, new Rect(i * newTex.width / questPuzzle.puzzleLevel, (questPuzzle.puzzleAltLevel - (j + 1)) * newTex.height / questPuzzle.puzzleAltLevel, newTex.width / questPuzzle.puzzleLevel, newTex.height / questPuzzle.puzzleAltLevel), Vector2.zero, 1);
            }
        }

        CreateWindow();
{'fraction_non_alphanumeric': 0.099644128113879, 'fraction_numerical': 0.006168446026097271, 'mean_word_length': 2.332806324110672, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '963793', 'n_tokens_mistral': 1382, 'n_tokens_neox': 1274, 'n_words': 251}