/*
	Copyright (C) 2021-2025 Mark Tyler

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 3 of the License, or
	(at your option) any later version.

	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 in the file COPYING.
*/

#ifndef MTLANTER_SDL_H_
#define MTLANTER_SDL_H_

#undef BIN_NAME
#define BIN_NAME "mtlanter-sdl"

#include <mtgin_sdl.h>

#include "lanter_be.h"



// Functions return: 0 = success, NULL = fail; unless otherwise stated.



#ifdef __cplusplus
extern "C" {
#endif

// C API



#ifdef __cplusplus
}

// C++ API

class Mainwindow;



class Mainwindow
{
public:
	explicit Mainwindow ( CommandLine & cline );

private:
	enum
	{
		MODE_NULL		= -1,
		MODE_INTERACTIVE	= 0,
		MODE_ANIMATION		= 2
	};

	int init_map ();

	void move_camera_home ( int top );

	void window_render () const;
	int window_event ( SDL_Event const * event );
	void window_close ();

	void output_image_file ();
	int export_image ( std::string const & filename ) const;

	void frame_cycle ();
	void mouse_click ( int dx, int dy );
	void key_click ( SDL_Event const * event );

	void set_mode ( int mode );

	void quit ();

/// ----------------------------------------------------------------------------

	int		m_quit		= 0;
	int		m_store_wh	= 0;
	int		m_mode		= MODE_NULL;
	int		m_anim_frame	= -1;

	CommandLine	& m_cline;

	TerraMap	m_map;
	TerraScene	m_scene;
	TerraCamera	m_camera;
	TerraAnimate	m_animate;

	mtGin::App	m_gin;
	mtGin::Window	m_window;

	MTKIT_RULE_OF_FIVE( Mainwindow )
};



#endif		// C++ API



#endif		// MTLANTER_SDL_H_

