repo_name
stringlengths 5
122
| path
stringlengths 3
232
| text
stringlengths 6
1.05M
|
|---|---|---|
zbigg/sandbox
|
json_mo_writer.h
|
<gh_stars>0
//
// Copyright (c) 2014, <NAME>
// This software licensed under terms described in LICENSE.txt
//
#ifndef json_mo_writer_h_included
#define json_mo_writer_h_included
#include "tinfra/json.h" // for json_renderer, json_writer
#include "tinfra/mo.h" // for mo_process
#include "tinfra/stream.h" // for output_stream
// namespace tinfra { // TBD, move it to tinfra
class json_mo_writer {
tinfra::output_stream& out;
tinfra::json_renderer renderer;
tinfra::json_writer writer;
public:
json_mo_writer(tinfra::output_stream& o):
out(o),
renderer(out),
writer(renderer)
{}
// MO contract
template <typename S, class T>
void leaf(S sym, T const& t)
{
if( writer.expected_value_kind() == tinfra::json_writer::UNNAMED ) {
writer.value(t);
} else {
writer.named_value(sym, t);
}
}
template <typename S, typename T>
void record(S sym, T const& v)
{
if( writer.expected_value_kind() == tinfra::json_writer::UNNAMED ) {
writer.begin_object();
} else {
writer.named_begin_object(sym);
}
tinfra::mo_process(v, *this);
writer.end_object();
}
template <typename S, typename T>
void sequence(S sym, T const& v)
{
if( writer.expected_value_kind() == tinfra::json_writer::UNNAMED ) {
writer.begin_array();
} else {
writer.named_begin_array(sym);
}
typedef typename T::const_iterator iterator;
for( iterator i = v.begin(); i != v.end(); ++i ) {
tinfra::process(S(0),*i, *this);
}
writer.end_array();
}
};
//} // end namespace tinfra
#endif // json_mo_writer_h_included
// jedit: :tabSize=8:indentSize=4:noTabs=true:mode=c++:
|
zbigg/sandbox
|
http.h
|
<filename>http.h<gh_stars>0
#ifndef tinfra_http_h_included_
#define tinfra_http_h_included_
#include "parser.h"
#include "lazy_byte_consumer.h"
#include <tinfra/tstring.h>
#include <tinfra/stream.h>
//#include <tinfra/optional.h>
namespace tinfra { namespace http {
enum protocol_version {
HTTP_1_0,
HTTP_1_1
};
struct request_header_entry {
std::string name;
std::string value;
};
struct request_header_data {
std::string method;
std::string request_uri;
protocol_version proto;
std::vector<request_header_entry> headers;
};
struct request_data {
request_header_data header;
std::string content;
};
struct response_header_data {
protocol_version proto;
int status;
std::string status_message;
std::vector<request_header_entry> headers;
};
struct response_data {
response_header_data header;
std::string content;
};
//void write(tinfra::output_stream&, response_header_data const&, optional<size_t> const& content_length);
//void write(tinfra::output_stream&, request_header_data const&, optional<size_t> const& content_length);
void write(tinfra::output_stream&, response_header_data const&, size_t content_length);
void write(tinfra::output_stream&, request_header_data const&, size_t content_length);
void write(tinfra::output_stream&, request_data const&);
void write(tinfra::output_stream&, response_data const& d);
// namespace S {
// extern symbol content_length;
// extern symbol keep_alive;
// }
struct protocol_listener {
virtual void request_line(
tstring const& method,
tstring const& request_uri,
tstring const& protocol_version) = 0;
virtual void response_line(
tstring const& protocol_version,
tstring const& status,
tstring const& status_string) = 0;
virtual void header(
tstring const& name,
tstring const& value) = 0;
virtual void finished_headers() {}
virtual void content(
tstring const& data,
bool last) = 0;
virtual ~protocol_listener();
};
class protocol_parser: public tinfra::parser {
public:
enum parse_mode {
SERVER,
CLIENT
};
protocol_parser(protocol_listener&, parse_mode);
int process_input(tinfra::tstring const& input);
void eof(tinfra::tstring const& unparsed_input);
private:
bool is_server() const { return mode_ == SERVER; }
bool is_client() const { return mode_ == CLIENT; }
enum {
EXPECTING_RESPONSE_LINE,
EXPECTING_REQUEST_LINE,
EXPECTING_HEADER,
EXPECTING_TRAILER,
EXPECTING_CONTENT,
EXPECTING_RESET
} state;
enum {
IDENTITY,
CHUNKED
} transfer_encoding;
// state updaters
void setup_content_retrieval();
void setup_initial_state();
// byte handlers
int request_line(tstring const& s);
int header_line(tstring const& s);
int trailer_line(tstring const& s);
int content_bytes(tstring const& s);
void handle_protocol_header(tstring const& name, tstring const& value);
void check_message_length(size_t length);
int process_content_further(tstring const& s, bool eof);
protocol_listener& sink_;
parse_mode mode_;
size_t current_body_chunk_length;
size_t current_body_chunk_readed;
tinfra::lazy_byte_consumer<protocol_parser> dispatch_helper_;
};
} } // end namespace tinfra::http
#endif // tinfra_http_h_included_
// jedit: :tabSize=8:indentSize=4:noTabs=true:mode=c++
|
zbigg/sandbox
|
msp430/msp430_hello_led.c
|
<reponame>zbigg/sandbox
#include <msp430.h>
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P1DIR |= 0x01; // Set P1.0 to output direction
for (;;)
{
volatile unsigned int i;
P1OUT ^= 0x01; // Toggle P1.0 using exclusive-OR
i = 50000; // Delay
do (i--);
while (i != 0);
}
}
|
zbigg/sandbox
|
json_mo_parser.h
|
<gh_stars>0
#ifndef json_mo_parser_h_included
#define json_mo_parser_h_included
#include "tinfra/json.h"
#include "tinfra/lex.h"
#include "tinfra/fmt.h"
#include "tinfra/trace.h"
#include "tinfra/mo.h"
#include <vector>
#include <string>
// namespace tinfra {
extern tinfra::module_tracer json_mo_parser_tracer;
class json_mo_parser {
tinfra::json_lexer& lexer;
tinfra::json_token current;
bool finished;
std::vector<std::string> name_stack;
public:
json_mo_parser(tinfra::json_lexer& lexer);
// MO visitor contract
template <typename S, typename T>
void record(S sym, T& v)
{
if( !match_name(sym) || finished ) {
return;
}
expect(tinfra::json_token::OBJECT_BEGIN);
next_or_fail("expected } or \"key\":value when parsing object but EOF found");
if( current.type == tinfra::json_token::OBJECT_END ) {
// short circuit for {}
next();
return;
}
while( true ) {
// 'foo'
expect(tinfra::json_token::STRING);
std::string key(current.value.str());
next();
// 'foo' :
expect(tinfra::json_token::COLON);
next_or_fail("expected value after ':'");
// try to parse matching field
push_expected_name(key);
tinfra::mo_mutate(v, *this);
pop_expected_name();
// now decide: next or end
if( current.type == tinfra::json_token::COMMA ) {
// , -> continue
next();
continue;
}
if( current.type == tinfra::json_token::OBJECT_END ) {
// } -> break
next();
break;
}
fail("expected ',' or '}' after value when parsing dictionary");
}
tinfra::mo_mutate(v, *this);
}
template <typename S, typename T>
void sequence(S sym, T& array)
{
if( !match_name(sym) || finished ) {
return;
}
expect(tinfra::json_token::ARRAY_BEGIN);
next_or_fail("expected ] or value when parsing array but EOF found");
if( current.type == tinfra::json_token::ARRAY_END ) {
// short circuit for []
next();
return;
}
while( true ) {
{
// ANYTHING
typename T::value_type tmp;
push_expected_name("!foo");
tinfra::mo_mutate("!foo", tmp, *this);
pop_expected_name();
using std::swap;
array.push_back(tmp);
}
// now decide: next or end
if( current.type == tinfra::json_token::COMMA ) {
// , -> continue
next_or_fail("expected value after ','");
continue;
}
if( current.type == tinfra::json_token::ARRAY_END ) {
// ] -> break
next();
break;
}
fail("expected ',' or ']' after value when parsing array");
}
}
template <typename S>
void leaf(S sym, std::string& v)
// std::string leaf
// store any value as string, even integers and doubles
{
if( !match_name(sym) || finished ) {
return;
}
switch( current.type ) {
case tinfra::json_token::STRING:
case tinfra::json_token::INTEGER:
case tinfra::json_token::DOUBLE:
v = current.value.str();
next();
break;
default:
fail(tsprintf("expected string for field '%s' but found (found %s)", get_full_field_name(sym), current.type));
}
}
template <typename S, typename I>
void integer_leaf(S sym, I& v)
// integer type leaf leaf
// store any value as string, even integers and doubles
{
if( !match_name(sym) || finished ) {
return;
}
if( current.type == tinfra::json_token::INTEGER ) {
v = tinfra::from_string<I>(current.value.str());
next();
} else {
fail(tsprintf("expected integer for field '%s' but found (found %s)", get_full_field_name(sym), current.type));
}
}
template <typename S>
void leaf(S sym, int& v) {
this->integer_leaf<int>(sym, v);
}
template <typename S>
void leaf(S sym, long& v) {
this->integer_leaf<long>(sym, v);
}
template <typename S>
void leaf(S sym, long long& v) {
this->integer_leaf<long long>(sym, v);
}
private:
void push_expected_name(std::string const& str);
void pop_expected_name();
bool match_name(tinfra::tstring const& name);
bool next();
void next_or_fail(const char* message);
void fail(std::string const& message);
void expect(tinfra::json_token::token_type tt);
std::string get_full_field_name(tinfra::tstring sym);
};
// namespace tinfra
#endif // json_mo_parser_h_included
// jedit: :tabSize=8:indentSize=4:noTabs=true:mode=c++:
|
zbigg/sandbox
|
birdplus.h
|
<filename>birdplus.h
#ifndef birdblus_h_included
#define birdblus_h_included
#include <type_traits>
#include <functional>
#include <memory>
#include <cassert>
#include <vector>
#include <exception>
#include <algorithm>
#include <iostream>
namespace birdplus {
/*
Promise::resolve(T) -> Promise<T>
Promise::resolve(Promise<T>) -> Promise<T>
Promise<T>::then( T -> R|P<R> ) returns Promise<R>
// note, always allow no-args function to then
// as someone might not be interested in result
Promise<T>::then( void -> R|P<R> ) returns Promise<R>
if R is Promise<R'>, then
// tuple integration, same as spread in bluebird/Q
Promise<tuple<T...>>::spread( T... -> (R|P<R>) -> Promise<R>
// can sugar version of then
Promise<tuple<T...>>::then( T... -> R) -> Promise<R>
// map
Promise::map(iterable<T>, T->R) -> Promise<iterable<R>>
Promise::map(iterable<Promise<T>>, T->R) -> Promise<iterable<R>>
// reduce is interesting
Promise::reduce(iterable<T>, R, (T,R)->R) -> Promise<R>
Promise::reduce(iterable<Promise<T>>, R, (T,R)->R) -> Promise<R>
// Promise.all(Promise<T>...) -> Promise<T...>
*/
template <typename T>
class Promise;
//
// PromisifyType<T> -> Promise<T>
// PromisifyType<Promise<T> -> Promise<T>
//
template <typename T>
struct PromisifyType {
typedef Promise<T> type;
};
template <typename T>
struct PromisifyType<Promise<T>> {
typedef Promise<T> type;
};
static_assert(std::is_same<Promise<int>, PromisifyType<int>::type>::value, "foo");
static_assert(std::is_same<Promise<int>, PromisifyType<Promise<int>>::type>::value, "foo");
namespace detail {
// this is weirdest thing i've ever seen
// in C++ WHY THE HELL void is not equal empty arg list !
template <typename T, typename F, typename V>
struct resolve_helper_int {
static void resolve(Promise<T> const& p, F f, V v);
};
template <typename T, typename F>
struct resolve_helper_int<T,F,void> {
static void resolve(Promise<T> const& p, F f);
};
template <typename F, typename V>
struct resolve_helper_int<void,F,V> {
static void resolve(Promise<void> const& p, F f, V v);
};
template <typename F>
struct resolve_helper_int<void,F,void> {
static void resolve(Promise<void> const& p, F f);
};
template <typename T,typename F>
void resolve_helper(Promise<T> p, F f) {
resolve_helper_int<T,F,void>::resolve(p,f);
}
template <typename T,typename F,typename V>
void resolve_helper(Promise<T> p, F f, V v) {
resolve_helper_int<T,F,V>::resolve(p,f,v);
}
//
// function_traits
// function_traits<T>::result_type
// function_traits<T>::arg<0>::type
//
// http://stackoverflow.com/questions/7943525/is-it-possible-to-figure-out-the-parameter-type-and-return-type-of-a-lambda
template <typename T>
struct function_traits
: public function_traits<decltype(&T::operator())>
{};
// For generic types, directly use the result of the signature of its 'operator()'
template <typename ClassType, typename ReturnType, typename... Args>
struct function_traits<ReturnType(ClassType::*)(Args...) const>
// we specialize for pointers to member function
{
enum { arity = sizeof...(Args) };
// arity is the number of arguments.
typedef ReturnType result_type;
template <size_t i>
struct arg
{
typedef typename std::tuple_element<i, std::tuple<Args...>>::type type;
// the i-th argument is equivalent to the i-th tuple element of a tuple
// composed of those arguments.
};
};
}
struct PromiseStateBase {
std::function<void(std::exception_ptr)> reject_callback;
std::exception_ptr exception;
bool forward_errors = true;
bool exception_handled = false;
~PromiseStateBase() {
if( exception && !exception_handled ) {
std::cerr << "some promise rejected, but not handled aaaaa!\n";
}
}
void reject(std::exception_ptr eptr) {
assert( !exception );
if( reject_callback ) {
this->exception_handled = true;
reject_callback(eptr);
reject_callback = nullptr;
}
this->exception = eptr;
}
template <typename F>
void add_reject_callback(F f) {
if( this->reject_callback ) {
auto old_callback = this->reject_callback;
this->reject_callback = [=](std::exception_ptr eptr){
old_callback(eptr);
f(eptr);
};
} else {
this->reject_callback = [=](std::exception_ptr eptr) {
f(eptr);
};
}
}
};
//
// Promise<T>
//
template <typename T>
class Promise {
struct SharedState: public PromiseStateBase {
std::function<void(T const&)> accept_callback;
std::unique_ptr<T> value;
void settle(T v) {
assert(! value && !exception);
if( accept_callback ) {
accept_callback(v);
accept_callback = nullptr;
}
value.reset(new T(std::move(v)));
}
};
std::shared_ptr<SharedState> state;
public:
Promise(): state(new SharedState) {}
Promise(Promise<T> const&) = default;
Promise(Promise<T>&&) = default;
Promise& operator=(Promise const&) = default;
template <typename ExecutorFn>
Promise(ExecutorFn executor):
state(new SharedState)
{
const auto resolve = [this](T value) {
this->settle(value);
};
const auto reject = [this](std::exception_ptr eptr) {
this->reject(eptr);
};
try {
executor(resolve, reject);
} catch( ... ) {
this->reject(std::current_exception());
}
}
static Promise<T> resolve(T v) {
Promise<T> tmp;
tmp.settle(v);
return tmp;
}
Promise<T> const& settle(T v) const {
state->settle(v);
return *this;
}
Promise<T> const& settle(Promise<T> p) const {
std::shared_ptr<SharedState> state_ref(state);
p.then([state_ref](T v) {
state_ref->settle(v);
});
return *this;
}
void reject(std::exception_ptr eptr) const {
state->reject(eptr);
}
template <typename ET>
void reject(ET e) const {
state->reject(std::make_exception_ptr(e));
}
static T udmmy;
template <typename F>
auto then(F f) const -> typename PromisifyType<decltype(f(udmmy))>::type {
typename PromisifyType<decltype(f(udmmy))>::type result;
if( state->forward_errors && state->exception ) {
state->exception_handled = true;
result.reject(state->exception);
} else if( state->value) {
detail::resolve_helper(result,f,*state->value.get());
} else {
if( state->accept_callback ) {
auto old_callback = state->accept_callback;
state->accept_callback = [=](T const& v) {
old_callback(v);
detail::resolve_helper(result,f, v);
};
} else {
state->accept_callback = [=](T const& v) {
detail::resolve_helper(result,f, v);
};
}
if( state->forward_errors ) {
state->add_reject_callback([=](std::exception_ptr eptr){
result.reject(eptr);
});
}
}
return result;
}
static std::exception_ptr uddmy2;
template <typename F> // F: (exception_ptr) -> R
auto error(F f) const -> typename PromisifyType<decltype(f(uddmy2))>::type {
typename PromisifyType<decltype(f(uddmy2))>::type result;
if( state->forward_errors ) {
state->reject_callback = nullptr;
state->forward_errors = false;
}
if( state->exception) {
detail::resolve_helper(result, f, state->exception);
} else {
state->add_reject_callback([=](std::exception_ptr eptr) {
detail::resolve_helper(result, f, eptr);
});
}
return result;
}
};
//
// Promise<void>
//
template <>
class Promise<void> {
struct SharedState: public PromiseStateBase {
std::function<void()> accept_callback;
bool settled = false;
void settle() {
assert(!settled && !exception);
if( accept_callback ) {
accept_callback();
accept_callback = nullptr;
}
settled = true;
}
};
std::shared_ptr<SharedState> state;
public:
Promise(): state(new SharedState) {}
Promise(Promise<void> const&) = default;
Promise(Promise<void>&&) = default;
template <typename ExecutorFn>
Promise(ExecutorFn executor):
state(new SharedState)
{
const auto resolve = [this]() {
this->settle();
};
const auto reject = [this](std::exception_ptr eptr) {
this->reject(eptr);
};
try {
executor(resolve, reject);
} catch( ... ) {
this->reject(std::current_exception());
}
}
static Promise<void> resolve() {
Promise<void> tmp;
tmp.settle();
return tmp;
}
Promise<void> const& settle() const {
state->settle();
return *this;
}
Promise<void> const& settle(Promise<void> p) const {
std::shared_ptr<SharedState> state_ref(state);
p.then([state_ref]() {
state_ref->settle();
});
return *this;
}
void reject(std::exception_ptr eptr) const {
state->reject(eptr);
}
template <typename ET>
void reject(ET e) const {
state->reject(std::make_exception_ptr(e));
}
template <typename F> // F: () -> R
auto then(F f) const -> typename PromisifyType<decltype(f())>::type {
typename PromisifyType<decltype(f())>::type result;
if( state->exception && !state->reject_callback) {
state->exception_handled = true;
result.reject(state->exception);
} else if( state->settled ) {
detail::resolve_helper(result,f);
} else {
if( state->accept_callback ) {
auto old_callback = state->accept_callback;
state->accept_callback = [=]() {
old_callback();
detail::resolve_helper(result,f);
};
} else {
state->accept_callback = [=]() {
detail::resolve_helper(result,f);
};
}
if( state->forward_errors ) {
state->add_reject_callback([=](std::exception_ptr eptr) {
result.reject(eptr);
});
}
}
return result;
}
template <typename F> // F: (exception_ptr) -> R
auto error(F f) const -> typename PromisifyType<typename detail::function_traits<F>::result_type>::type {
typename PromisifyType<typename detail::function_traits<F>::result_type>::type result;
if( state->forward_errors ) {
state->reject_callback = nullptr;
state->forward_errors = false;
}
if( state->exception) {
state->exception_handled = true;
detail::resolve_helper(result, f, state->exception);
} else {
state->add_reject_callback([=](std::exception_ptr eptr) {
detail::resolve_helper(result, f, eptr);
});
}
return result;
}
};
namespace detail {
// this is weirdest thing i've ever seen
// in C++ WHY THE HELL void is not equal empty arg list !
template <typename T, typename F, typename V>
void resolve_helper_int<T,F,V>::resolve(Promise<T> const& p, F f, V v) {
try {
p.settle(f(std::move(v)));
} catch(...) {
p.reject(std::current_exception());
}
};
template <typename T, typename F>
void resolve_helper_int<T,F,void>::resolve(Promise<T> const& p, F f) {
try {
p.settle(f());
} catch(...) {
p.reject(std::current_exception());
}
};
template <typename F, typename V>
void resolve_helper_int<void,F,V>::resolve(Promise<void> const& p, F f, V v) {
try {
f(std::move(v));
p.settle();
} catch(...) {
p.reject(std::current_exception());
}
}
template <typename F>
void resolve_helper_int<void,F,void>::resolve(Promise<void> const& p, F f) {
try {
f();
p.settle();
} catch(...) {
p.reject(std::current_exception());
}
}
template <typename T>
struct to_promise_helper {
static Promise<T> to_promise(T v) {
Promise<T> p;
p.settle(std::move(v));
return p;
}
};
template <typename T>
struct to_promise_helper<Promise<T>> {
static Promise<T> to_promise(Promise<T> p) {
return p;
}
};
}
//
// to_promise<T>(v) -> Promise<T>
//
// for actual value, return settled promise
// for promise, just return it
//
template <typename T>
typename PromisifyType<T>::type to_promise(T v)
{
return detail::to_promise_helper<T>::to_promise(v);
}
template <typename T, typename R, typename F>
Promise<R> reduce(std::vector<Promise<T>> const& list, R initial, F f) {
if( list.begin() == list.end() ) {
return to_promise(initial);
}
Promise<R> pr = list.begin()->then([f,initial](T const& v) {
return f(v, initial);
});
auto pit = list.begin();
pit++;
while( pit != list.end() ) {
Promise<T> pt = *pit++;
pr = pr.then([pt,f](R r) -> Promise<R> {
return pt.then([r,f](T const& v) -> R {
return f(v, r);
});
});
}
return pr;
}
template <typename T, typename R, typename F>
std::vector<typename PromisifyType<R>::type> map(std::vector<Promise<T>> const& list, F f) {
std::vector<typename PromisifyType<R>::type> result;
result.resize(list.size());
std::transform(list.begin(), list.end(), result.begin(), [f](Promise<T> const& p) {
return p.then(f);
});
return result;
}
} // end namespace birdplus
#endif // birdblus_h_included
|
zbigg/sandbox
|
msp430/msp430_hello_world_led_interrupts.c
|
<filename>msp430/msp430_hello_world_led_interrupts.c
#include <msp430.h>
#define LED_0 BIT0
#define LED_1 BIT6
#define LED_OUT P1OUT
#define LED_DIR P1DIR
unsigned int timerCount = 0;
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
LED_DIR |= (LED_0 + LED_1); // Set P1.0 and P1.6 to output direction
LED_OUT &= ~(LED_0 + LED_1); // Set the LEDs off
CCTL0 = CCIE;
TACTL = TASSEL_2 + MC_2; // Set the timer A to SMCLCK, Continuous
P1DIR |= 0x01;
__enable_interrupt();
__bis_SR_register(LPM0_bits + GIE); // LPM0 with interrupts enabled
}
// Timer A0 interrupt service routine
// Timer A0 interrupt service routine
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=TIMER0_A0_VECTOR
__interrupt void Timer_A (void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(TIMER0_A0_VECTOR))) Timer_A (void)
#else
#error Compiler not supported!
#endif
{
timerCount = (timerCount + 1) % 8;
if(timerCount ==0) {
P1OUT ^= (LED_0 + LED_1);
//P1OUT ^= 0x01;
}
}
|
zbigg/sandbox
|
parser.h
|
<filename>parser.h
//
// Copyright (C) 2008 <NAME> <<EMAIL>>,
// licensed to the public under the terms of the GNU GPL (>= 2)
// see the file COPYING for details
// I.e., do what you like, but keep copyright and there's NO WARRANTY.
//
#ifndef tinfra_parser_h__
#define tinfra_parser_h__
#include "tinfra/tstring.h"
namespace tinfra {
class parser {
public:
virtual int process_input(tinfra::tstring const& input) = 0;
virtual void eof(tinfra::tstring const& unparsed_input) = 0;
virtual ~parser() {}
};
} // end namespace tinfra
#endif // tinfra_parser_h__
// jedit: :tabSize=8:indentSize=4:noTabs=true:mode=c++
|
Labmann004/Minesweeper
|
tile.h
|
#pragma once
#include <SFML/Graphics.hpp>
#include <iostream>
#include <fstream>
#include "textureManager.h"
#include <cstdlib>
#include <map>
using namespace std;
using namespace sf;
class tile {
public:
vector<tile> adjacent;
int displayCondition ; //contains all realConditions but has its own values (11,12,13)
int realCondition;
bool alreadyRevealed;
void setDisplayCondition(int i) {
displayCondition = i;
}
void setRealCondition(int i) {
realCondition = i;
}
void setalreadyRevealed(bool i) {
alreadyRevealed = i;
}
void displayEqualsReal() {
displayCondition = realCondition;
}
/*
0: mine
1. 1round
2. 2 around
.
.
.
8. 8 mines around
9. default condition(hidden tile) //not for real condition , only for display
10. real default condition underneath hidden(texture as revealed) ****empty tile****
11. flagged // for display
12. already revealed
*/
void tiledefault() {
displayCondition = 9;
}
void setunRecursive() {
realCondition = 12;
}
};
|
Labmann004/Minesweeper
|
board.h
|
<filename>board.h
#pragma once
#include "tile.h"
#include <vector>
#include <random>
#include "textureManager.h"
#include <string>
textureManage manager;
map<string, Sprite> tileSpriteMap = manager.tileTextures();
map<string, Sprite> boardSpriteMap = manager.boardElements();
#define width 32
class board {
public:
tile Tiles[16][25];
int flags_remain = 50;
int mines = 0;
bool isWin= false;
bool isLost= false;
bool debugMode= false;
bool revealed = 0;
void setisWin(bool i) {
isWin = i;
}
void setDebug(bool i) {
debugMode = i;
}
void setisLost(bool i) {
isLost = i;
}
vector<int> Generatebomblist(int min, int max, int num)
{
int random;
vector<int> bomblist;
vector<int> remain;
for (int i = min; i < max + 1; i++)
{
remain.push_back(i);
}
srand((unsigned)time(0));
for (int i = 0; i < num; i++)
{
do {
random = min + rand() % (max - min + 1);
} while (remain.at(random - min) == -1);
bomblist.push_back(random);
remain.at(random - min) = -1;
}
return bomblist;
}
string checkPosition(int i,int j) {
if (i == 0 && j == 0) return"top left";
else if (i == 0 && j == 24) return "top right";
else if (i == 15 && j == 0) return "bottom left";
else if (i == 15 && j == 24) return "bottom right";
else if (i == 0) return "top";
else if (j == 0) return "left side";
else if (j == 24) return "right side";
else if (i == 15) return "bottom";
else return "middle";
}
void flag(int i, int j) {
if (Tiles[i][j].displayCondition == 9)
{
Tiles[i][j].displayCondition = 11;
}
if (Tiles[i][j].displayCondition == 11)
{
Tiles[i][j].displayCondition = 9;
}
}
void setMinesAround() {
for (int i = 0; i <16; i++)
{
for (int j = 0; j < 25; j++)
{
int Neighborcounter = 0;
if (Tiles[i][j].realCondition != 0) //check if the tile is not mine
{
if (Tiles[i - 1][j - 1].realCondition == 0 && (i != 0) && (j != 0))
Neighborcounter++;
if (Tiles[i - 1][j].realCondition == 0 && (i != 0))
Neighborcounter++;
if (Tiles[i - 1][j + 1].realCondition == 0 && (i != 0) && (j != 24))
Neighborcounter++;
if (Tiles[i][j - 1].realCondition == 0 && (j!=0))
Neighborcounter++;
if (Tiles[i][j + 1].realCondition == 0 && (j!=24))
Neighborcounter++;
if (Tiles[i + 1][j - 1].realCondition == 0 && (i!=15)&&(j!=0))
Neighborcounter++;
if (Tiles[i + 1][j].realCondition == 0 && (i!=15))
Neighborcounter++;
if (Tiles[i + 1][j + 1].realCondition == 0 && (i != 15) && (j != 24))
{
Neighborcounter++;
}
if (Neighborcounter == 0)//no mines around that tile
Tiles[i][j].setRealCondition(10);// set to default empty condition
else
Tiles[i][j].setRealCondition(Neighborcounter);
}
}
}
}
bool winCondition() {
bool win =true;
for (int i = 0; i < 16; i++) {
for (int j = 0; j < 25; j++)
{
if (Tiles[i][j].realCondition == 0 && Tiles[i][j].displayCondition != 11) win = false;
if (Tiles[i][j].realCondition != 0 && Tiles[i][j].displayCondition == 9) win = false;
}
}
return win;
}
void setRevealCondition(int i, int j)//for empty tiles
{
Tiles[i][j].setunRecursive(); //same from 10, just to differ to avoid recursive error
if ((i != 0) && (j != 0) && hasMineArond(i, j) && Tiles[i - 1][j - 1].displayCondition != 11) Tiles[i - 1][j - 1].displayEqualsReal();
if ((Tiles[i - 1][j].displayCondition != 11) && (i != 0) && hasMineArond(i - 1, j) || Tiles[i - 1][j].realCondition == 10) Tiles[i - 1][j].displayEqualsReal();
if ((i != 0) && (j != 0) && hasMineArond(i, j) && Tiles[i - 1][j + 1].displayCondition != 11) Tiles[i - 1][j + 1].displayEqualsReal();//end of checking upper blocks
if ((j != 24) && (hasMineArond(i, j + 1) || Tiles[i][j + 1].realCondition == 10) && (Tiles[i][j + 1].displayCondition != 11))Tiles[i][j + 1].displayEqualsReal();
if ((i != 15) && (j != 24) && (hasMineArond(i + 1, j + 1)) && (Tiles[i + 1][j + 1].displayCondition != 11)) Tiles[i + 1][j + 1].displayEqualsReal();
if ((Tiles[i + 1][j].displayCondition != 11) && (i != 15) && (hasMineArond(i + 1, j)) || Tiles[i + 1][j].realCondition == 10) Tiles[i + 1][j].displayEqualsReal();// end of checking lower blockes
if ((Tiles[i + 1][j - 1].displayCondition != 11) && (i != 15) && (j != 0) && (hasMineArond(i + 1, j - 1))) Tiles[i + 1][j - 1].displayEqualsReal();
if (j != 0 && (hasMineArond(i, j - 1) && (Tiles[i][j - 1].displayCondition != 11) || Tiles[i][j - 1].realCondition == 10)) Tiles[i][j - 1].displayEqualsReal();//end of checking left and right
}
bool isflagged(int i, int j) {
return Tiles[i][j].displayCondition == 11;
}
void emptyField() {
for (int i = 0; i < 16; i++) {
for (int j = 0; j < 25; j++) {
Tiles[i][j].setRealCondition(10);
Tiles[i][j].tiledefault();
}
}
}
void generateBoard() {
vector<int> bombList = Generatebomblist(0, 399, 50);
flags_remain = 50;
//generate random mine position
emptyField();
mines = 0;
for (int i = 0; i < 16; i++) {
for (int j = 0; j < 25; j++) {
for (int bombCount = 0; bombCount < bombList.size(); bombCount++) {
if (bombList[bombCount] == 25 * i + j)
{
bombCount++;
Tiles[i][j].realCondition=0;//set the mine tile
}
}
if (Tiles[i][j].realCondition == 0) {
mines++;
cout << 0;
}
else {
cout << 1;
}
Tiles[i][j].tiledefault(); //set display mode as hidden to 9
}
cout << endl;
}
setMinesAround();
bombList.clear();
}
bool hasMineArond(int i,int j)//aren't mines, aren't flagged, realcondition as showing numbers
{
return(Tiles[i][j].realCondition >=1 && Tiles[i][j].realCondition < 9);
}
void RevealemptyTiles(int i, int j)
{
if (Tiles[i][j].realCondition == 10)
{
setRevealCondition(i, j);
if ((i != 15) && Tiles[i + 1][j].realCondition == 10)RevealemptyTiles(i + 1, j);
if ((j != 0) && Tiles[i][j - 1].realCondition == 10)RevealemptyTiles(i, j - 1);
if ((j != 24) && Tiles[i][j + 1].realCondition == 10)RevealemptyTiles(i, j + 1);
if ((i != 0) && Tiles[i - 1][j].realCondition == 10)RevealemptyTiles(i - 1, j);
}
}
//start of draw functions
void drawTile(Sprite obj, int i, int j, RenderWindow& w) {
obj.setPosition(j * width, i * width);
w.draw(obj);
}
void drawBlock(Sprite face, int j, int i, RenderWindow& w) {
face.setPosition(j, i);
w.draw(face);
}
void drawDigit( RenderWindow& w,int flagsRemain) {
Sprite negative = boardSpriteMap["digits"];
negative.setTextureRect(Rect<int>(21 * 10, 0, 21, 32));
negative.setPosition(0, 520);
if (flagsRemain < 0) {
w.draw(negative);
flagsRemain = -flagsRemain;
}
int T=0;
int O=0;
if (flagsRemain > 10 || flagsRemain == 10) {
T = flagsRemain / 10;
O = flagsRemain %10;
}
else {
T = 0;
O = flagsRemain;
}
Sprite tens = boardSpriteMap["digits"];
tens.setTextureRect(Rect<int>(21 * T, 0, 21, 32));
tens.setPosition(44, 520);
Sprite ones = boardSpriteMap["digits"];
ones.setTextureRect(Rect<int>(21 * O, 0, 21, 32));
ones.setPosition(66, 520);
Sprite hundreds= boardSpriteMap["digits"];
hundreds.setTextureRect(Rect<int>(0, 0, 21, 32));
hundreds.setPosition(22, 520);
w.draw(hundreds);
w.draw(tens);
w.draw(ones);
}
void revealAllbomb() {
for (int i = 0; i <= 15; i++)
{
for (int j = 0; j <= 24; j++)
{
if(Tiles[i][j].realCondition==0)
Tiles[i][j].displayEqualsReal();
}
}
}
void readTestFile(int choice)
{
flags_remain = 50;
emptyField();
ifstream inFile;
if (choice == 1)
{
inFile.open("boards/testboard1.brd");
}
if (choice == 2)
{
inFile.open("boards/testboard2.brd");
}
if (choice == 3) {
inFile.open("boards/testboard3.brd");
}
string temp;
if (inFile.is_open())
{
string temp ;
int i = 0;
while (getline(inFile, temp))
{
for (int j = 0; j < 25; j++)
{
if (j == 24) i++; //change line
int a = temp[j] - 48;
cout << a;
if(a == 1) Tiles[i][j].setRealCondition(0);
}
cout << endl;
}
}
inFile.close();
setMinesAround();
}
void drawAll(RenderWindow &game) {
game.clear(Color::White);
drawDigit(game, flags_remain);
if (isWin == true&&isLost==false) drawBlock(boardSpriteMap["face win"], 368, 520, game);
if (isWin == false&&isLost==true) drawBlock(boardSpriteMap["face lose"],368,520, game);
if (isWin == false && isLost == false) drawBlock(boardSpriteMap["face happy"], 368, 520, game); //draw faces...win lose happy
drawBlock(boardSpriteMap["debug"], 500, 520, game);
drawBlock(boardSpriteMap["test1"], 567, 520, game);
drawBlock(boardSpriteMap["test2"], 631, 520, game);
drawBlock(boardSpriteMap["test3"], 695, 520, game);
for (int i = 0; i < 16; i++) {
for (int j = 0; j < 25; j++) {
int obj = Tiles[i][j].displayCondition;
switch (obj) {
case 0: {
drawTile(tileSpriteMap["revealed"], i, j, game);
drawTile(tileSpriteMap["mine"], i, j, game);
break;
}
case 1: {
drawTile(tileSpriteMap["revealed"], i, j, game);
drawTile(tileSpriteMap["one"], i, j, game);
break;
}
case 2: {
drawTile(tileSpriteMap["revealed"], i, j, game);
drawTile(tileSpriteMap["two"], i, j, game);
break; }
case 3: {
drawTile(tileSpriteMap["revealed"], i, j, game);
drawTile(tileSpriteMap["three"], i, j, game);
break; }
case 4: {
drawTile(tileSpriteMap["revealed"], i, j, game);
drawTile(tileSpriteMap["four"], i, j, game);
break; }
case 5: {
drawTile(tileSpriteMap["revealed"], i, j, game);
drawTile(tileSpriteMap["five"], i, j, game);
break; }
case 6: {
drawTile(tileSpriteMap["revealed"], i, j, game);
drawTile(tileSpriteMap["six"], i, j, game);
break; }
case 7: {
drawTile(tileSpriteMap["revealed"], i, j, game);
drawTile(tileSpriteMap["seven"], i, j, game);
break;
}
case 8: {
drawTile(tileSpriteMap["revealed"], i, j, game);
drawTile(tileSpriteMap["eight"], i, j, game);
break; }
case 9: {
drawTile(tileSpriteMap["revealed"], i, j, game);
drawTile(tileSpriteMap["hidden"], i, j, game);
break;
}
case 10: {
drawTile(tileSpriteMap["revealed"], i, j, game);
break;
}
case 11: {
drawTile(tileSpriteMap["revealed"], i, j, game);
drawTile(tileSpriteMap["hidden"], i, j, game);
drawTile(tileSpriteMap["flag"], i, j, game);
break;
}
case 12: {
drawTile(tileSpriteMap["revealed"], i, j, game);
break;
}
case 13: {
drawTile(tileSpriteMap["revealed"], i, j, game);
drawTile(tileSpriteMap["mine"], i, j, game);
drawTile(tileSpriteMap["flag"], i, j, game);
break;
}
}//end of switch
}
}
}// end of drawAll
};
|
Labmann004/Minesweeper
|
textureManager.h
|
<gh_stars>0
#pragma once
#include <SFML/Graphics.hpp>
#include <map>
using namespace std;
using namespace sf;
class textureManage {
public:
Texture one;
Texture two;
Texture three;
Texture four;
Texture five;
Texture six;
Texture seven;
Texture eight;
Texture hidden;
Texture revealed;
Texture flag;
Texture mine;
Texture debug;
Texture digits;
Texture faceHappy;
Texture faceLose;
Texture faceWin;
Texture test1;
Texture test2;
Texture test3;
map<string, Sprite> tileTextures() {
map<string, Sprite> tileSprites;
one.loadFromFile("images/number_1.png");//1
tileSprites.emplace("one", Sprite(one));
two.loadFromFile("images/number_2.png");//2
tileSprites.emplace("two", Sprite(two));
three.loadFromFile("images/number_3.png");//3
tileSprites.emplace("three", Sprite(three));
four.loadFromFile("images/number_4.png");//4
tileSprites.emplace("four", Sprite(four));
five.loadFromFile("images/number_5.png");//5
tileSprites.emplace("five", Sprite(five));
six.loadFromFile("images/number_6.png");//6
tileSprites.emplace("six", Sprite(six));
seven.loadFromFile("images/number_7.png");//7
tileSprites.emplace("seven", Sprite(seven));
eight.loadFromFile("images/number_8.png");//8
tileSprites.emplace("eight", Sprite(eight));
hidden.loadFromFile("images/tile_hidden.png");//9
tileSprites.emplace("hidden", Sprite(hidden));
revealed.loadFromFile("images/tile_revealed.png");//10
tileSprites.emplace("revealed", Sprite(revealed));
flag.loadFromFile("images/flag.png");//11
tileSprites.emplace("flag", Sprite(flag));
mine.loadFromFile("images/mine.png");//0
tileSprites.emplace("mine", Sprite(mine));
return tileSprites;
}
map<string, Sprite> boardElements() {
map<string, Sprite> elementSprites;
debug.loadFromFile("images/debug.png");
elementSprites.emplace("debug", Sprite(debug));
digits.loadFromFile("images/digits.png");
elementSprites.emplace("digits", Sprite(digits));
faceHappy.loadFromFile("images/face_happy.png");
elementSprites.emplace("face happy", Sprite(faceHappy));
faceLose.loadFromFile("images/face_lose.png");
elementSprites.emplace("face lose", Sprite(faceLose));
faceWin.loadFromFile("images/face_win.png");
elementSprites.emplace("face win", Sprite(faceWin));
test1.loadFromFile("images/test_1.png");
elementSprites.emplace("test1", Sprite(test1));
test2.loadFromFile("images/test_2.png");
elementSprites.emplace("test2", Sprite(test2));
test3.loadFromFile("images/test_3.png");
elementSprites.emplace("test3", Sprite(test3));
return elementSprites;
}
};
|
musicinmybrain/fast_float
|
tests/build_tests/issue72/test.h
|
<filename>tests/build_tests/issue72/test.h
#pragma once
#include "fast_float/fast_float.h"
|
fakeid30/UVA-problems
|
Jumping Mario!.c
|
<filename>Jumping Mario!.c
#include<stdio.h>
int main()
{
int T,N,Array[50],i,j,c1,c2;
scanf("%d",&T);
for(i=1;i<=T;i++)
{
c1=0;
c2=0;
scanf("%d",&N);
for(j=0;j<N;j++)
{
scanf("%d",&Array[j]);
}
for(j=0;j<N-1;j++)
{
if(Array[j]<Array[j+1])
{
c1++;
}
else if(Array[j]>Array[j+1])
{
c2++;
}
}
printf("Case %d: %d %d\n",i,c1,c2);
}
return 0;
}
|
fakeid30/UVA-problems
|
Beat the spread.c
|
<reponame>fakeid30/UVA-problems<filename>Beat the spread.c
#include<stdio.h>
int main()
{
int t,s,d,i,r;
scanf("%d",&t);
while(t--)
{
i=0;
scanf("%d%d",&s,&d);
if(d>s || (s+d)%2!=0)
{
printf("impossible\n");
}
else
{
i=(s+d)/2;
r=s-i;
printf("%d %d\n",i,r);
}
}
return 0;
}
|
fakeid30/UVA-problems
|
Above average.c
|
#include<stdio.h>
int main()
{
// test add
int t,i=1,j,n,array_num[1000],c,sum;
double avg,total;
scanf("%d",&t);
while(t--)
{
c=0;
sum=0;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&array_num[i]);
sum=sum+array_num[i];
}
avg=sum*1.00/n;
for(i=0;i<n;i++)
{
if(array_num[i]>avg)
{
c++;
}
}
total=(c*100.00)/n;
printf("%.3lf%%\n",total);
}
return 0;
}
|
fakeid30/UVA-problems
|
Hello world.c
|
#include<stdio.h>
int main()
{
int n,c,i,j=1;
while(scanf("%d",&n))
{
if(n<0)
{
break;
}
c=0;
i=1;
while(i<n)
{
i=i+c;
c++;
}
printf("Case %d: %d\n",j,c);
j++;
}
return 0;
}
|
fakeid30/UVA-problems
|
Cola.c
|
#include<stdio.h>
int main()
{
int n,sum;
while(scanf("%d",&n)==1)
{
sum=n;
while(n>=3)
{
sum=sum+n/3;
n=n/3+n%3;
}
if(n==2)
{
sum++;
}
printf("%d\n",sum);
}
return 0;
}
|
fakeid30/UVA-problems
|
Leap year or Not leap year and....c
|
#include<stdio.h>
int main()
{
int year;
while(scanf("%d",&year)!=EOF)
{
if((year%400==0) || (year%4==0 && year%100!=0))
{
printf("This is leap year.\n");
if(year%15==0)
{
printf("This is huluculu festival year.\n");
}
if(year%55==0)
{
printf("This is bulukulu festival year.\n");
}
}
else if(year%15==0)
{
printf("This is huluculu festival year.\n");
}
else
{
printf("This is an ordinary year.\n");
}
printf("\n");
}
return 0;
}
|
fakeid30/UVA-problems
|
Etruscan warriors never play chess.c
|
<gh_stars>1-10
#include<stdio.h>
#include<math.h>
int main()
{
long long int n,sum,t;
scanf("%lld",&t);
while(t--)
{
scanf("%lld",&n);
sum=((sqrt(1+8*n))-1)/2;
printf("%lld\n",sum);
}
return 0;
}
|
fakeid30/UVA-problems
|
Brick game.c
|
<filename>Brick game.c
#include<stdio.h>
int main()
{
int test,i,j,array[9],n;
scanf("%d",&test);
if(test<=100)
{
for(i=1;i<=test;i++)
{
scanf("%d",&n);
for(j=0;j<n;j++)
{
scanf("%d",&array[j]);
}
printf("Case %d: %d\n",i,array[n/2]);
}
}
return 0;
}
|
fakeid30/UVA-problems
|
Back to high school physics.c
|
#include<stdio.h>
int main()
{
int v,t;
while(scanf("%d%d",&v,&t)!=EOF)
{
printf("%d\n",2*v*t);
}
return 0;
}
|
fakeid30/UVA-problems
|
What's the frequency.c
|
#include<stdio.h>
#include<string.h>
int main()
{
char string[1000000],i,l,ch[1000000],j,c;
while(gets(string))
{
l=strlen(string);
for(i=0;i<l;i++)
{
ch[i]=-1;
}
for(i=0;i<l;i++)
{
c=1;
for(j=i+1;j<l;j++)
{
if(string[i]==string[j] && string[i]!=32)
{
c++;
ch[j]=0;
}
}
if(ch[i]!=0)
{
ch[i]=c;
}
}
c=ch[0];
for(i=1;i<l;i++)
{
if(c<ch[i])
{
c=ch[i];
}
}
printf("%s\n",ch);
}
return 0;
}
|
fakeid30/UVA-problems
|
Cost cutting.c
|
<reponame>fakeid30/UVA-problems<gh_stars>1-10
#include<stdio.h>
int main()
{
int a,b,c,t,i=1;
scanf("%d",&t);
while(i<=t && t<20)
{
scanf("%d%d%d",&a,&b,&c);
if(a<1000 || a>10000 || b<1000 || b>10000 || c<1000 || c>10000)
{
break;
}
if((a<=b && a>=c) || (a<=c && a>=b))
{
printf("Case %d: %d\n",i,a);
}
else if((b<=a && b>=c) || (b<=c && b>=a))
{
printf("Case %d: %d\n",i,b);
}
else if((c<=a && c>=b) || (c<=b && c>=a))
{
printf("Case %d: %d\n",i,c);
}
i++;
}
return 0;
}
|
fakeid30/UVA-problems
|
Train swapping.c
|
#include<stdio.h>
int main()
{
int n,l,array[51],i,j,k,t;
scanf("%d",&n);
while(n--)
{
k=0;
scanf("%d",&l);
for(i=0;i<l;i++)
{
scanf("%d",&array[i]);
}
}
return 0;
}
|
fakeid30/UVA-problems
|
To carry or not to carry.c
|
<reponame>fakeid30/UVA-problems
#include<stdio.h>
int main()
{
int x,y;
while(scanf("%d%d",&x,&y)!=EOF)
{
printf("%d\n",x^y);
}
return 0;
}
|
fakeid30/UVA-problems
|
Searching for Nessy.c
|
<reponame>fakeid30/UVA-problems<filename>Searching for Nessy.c<gh_stars>1-10
#include<stdio.h>
int main()
{
int t,a,b,i;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&a,&b);
a=a/3;
b=b/3;
printf("%d\n",a*b);
}
return 0;
}
|
fakeid30/UVA-problems
|
one, two, three.c
|
<gh_stars>1-10
#include<stdio.h>
int main()
{
int t;
char string[10];
scanf("%d",&t);
while(t--)
{
scanf("%s",&string);
if(string[0]=='o' || string[1]=='n' || string[2]=='e')
{
printf("1\n");
}
else if(string[0]=='t' || string[1]=='w' || string[2]=='o')
{
printf("2\n");
}
else if(string[0]=='t' || string[1]=='h' || string[2]=='r' || string[0]=='e' || string[1]=='e')
{
printf("3\n");
}
}
return 0;
}
|
fakeid30/UVA-problems
|
Primary Arithmetic.c
|
#include<stdio.h>
int main()
{
long int a,b;
int s,c;
while(scanf("%ld%ld",&a,&b))
{
if(a==0 && b==0)
{
break;
}
c=0;
s=0;
while(a||b)
{
s=(a%10+b%10+s)/10;
a=a/10;
b=b/10;
c=c+s;
}
if(c==0)
{
printf("No carry operation.\n");
}
else if(c==1)
{
printf("1 carry operation.\n");
}
else
{
printf("%d carry operations.\n",c);
}
}
return 0;
}
|
fakeid30/UVA-problems
|
TEX Quotes.c
|
#include<stdio.h>
#include<string.h>
int main()
{
char string[10000];
int i,c,l;
while(gets(string))
{
l=0;
c=0;
l=strlen(string);
for(i=0;i<l;i++)
{
if(string[i]=='"')
{
c++;
if(c%2==0)
{
printf("''");
}
else
{
printf("``");
}
}
else
{
printf("%c",string[i]);
}
}
printf("\n");
}
return 0;
}
|
fakeid30/UVA-problems
|
Hajj e akbar.c
|
#include<stdio.h>
int main()
{
char s[5];
int i=1;
while(gets(s))
{
if(s[0]=='*')
{
break;
}
if(s[0]=='H')
{
printf("Case %d: Hajj-e-Akbar\n",i);
}
else if(s[0]=='U')
{
printf("Case %d: Hajj-e-Asghar\n",i);
}
i++;
}
return 0;
}
|
fakeid30/UVA-problems
|
Dollars.c
|
<filename>Dollars.c
#include<stdio.h>
int main()
{
int dollars;
while(scanf("%d",&dollars)!=EOF)
{
}
return 0;
}
|
fakeid30/UVA-problems
|
Automate the grades.c
|
#include<stdio.h>
int main()
{
int t,i,trm1,trm2,fnl,A,T1,T2,T3,s;
float av,total;
scanf("%d",&t);
for(i=1;i<=t;i++)
{
scanf("%d%d%d%d%d%d%d",&trm1,&trm2,&fnl,&A,&T1,&T2,&T3);
if(T1<T2)
{
s=T2;
T2=T1;
T1=s;
}
if(T2<T3)
{
s=T3;
T3=T2;
T2=s;
}
av=(T1+T2)/2;
total=trm1+trm2+fnl+A+av;
if(total>=90)
{
printf("Case %d: A\n",i);
}
else if(total>=80)
{
printf("Case %d: B\n",i);
}
else if(total>=70)
{
printf("Case %d: C\n",i);
}
else if(total>=60)
{
printf("Case %d: D\n",i);
}
else
{
printf("Case %d: F\n",i);
}
}
return 0;
}
|
fakeid30/UVA-problems
|
Event planning.c
|
<gh_stars>1-10
#include<stdio.h>
int main()
{
int pa,b,h,w,p,be[13],i,array[18],j;
while(scanf("%d%d%d%d",&pa,&b,&h,&w)!=EOF)
{
i=0;
while(i<h)
{
scanf("%d",&p);
for(j=1;j<=w;j++)
{
scanf("%d",&be[j]);
if(be[j]<pa)
{
j=0;
break;
}
}
array[i]=j*b;
i++;
}
w=0;
for(i=0;i<h;i++)
{
for(j=i+1;j<h;j++)
{
if(array[i]>=array[j])
{
w=array[i];
array[i]=array[j];
array[j]=w;
}
}
}
for(i=0;i<h;i++)
{
printf("%d ",array[i]);
}
printf("\n");
if(array[0]==0 || array[0]>b)
{
printf("stay home\n");
}
else
{
printf("%d\n",array[0]);
}
}
return 0;
}
|
fakeid30/UVA-problems
|
Packing for holiday.c
|
<gh_stars>1-10
#include<stdio.h>
int main()
{
int t,l,w,h,i;
scanf("%d",&t);
for(i=1;i<=t;i++)
{
scanf("%d%d%d",&l,&w,&h);
if(l<=20 && w<=20 && h<=20)
{
printf("Case %d: good\n",i);
}
else
{
printf("Case %d: bad\n",i);
}
}
return 0;
}
|
fakeid30/UVA-problems
|
Optimal parking.c
|
#include<stdio.h>
int main()
{
int t,i,n,array[20],m,j;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&array[i]);
}
m=array[0];
for(i=1;i<n;i++)
{
if(m>array[i])
{
m=array[i];
}
}
j=array[0];
for(i=1;i<n;i++)
{
if(j<array[i])
{
j=array[i];
}
}
printf("%d\n",(j-m)*2);
}
return 0;
}
|
fakeid30/UVA-problems
|
The decoder.c
|
<filename>The decoder.c<gh_stars>1-10
#include<stdio.h>
#include<string.h>
int main()
{
int l,i;
char string[1000];
gets(string);
l=strlen(string);
for(i=0;i<l;i++)
{
string[i]=string[i]-7;
}
printf("%s\n",string);
return 0;
}
|
fakeid30/UVA-problems
|
Google is feeling lucky.c
|
<reponame>fakeid30/UVA-problems
#include<stdio.h>
#include<string.h>
int amin()
{
int t,r,i,j,k;
char string[100],string2[10];
scanf("%d",&t);
for(i=1;i<=t;i++)
{
for(j=1;j<=10;j++)
{
scanf("%d",&r);
}
}
}
|
fakeid30/UVA-problems
|
Lazy lumberjacks.c
|
<filename>Lazy lumberjacks.c<gh_stars>1-10
#include<stdio.h>
int main()
{
int t,a,b,c,i;
scanf("%d",&t);
for(i=1;i<=t;i++)
{
scanf("%d%d%d",&a,&b,&c);
if(a>0 && b>0 && c>0)
{
if((a+b)>c && (b+c)>a && (c+a)>b)
{
printf("OK\n");
}
else
{
printf("Wrong!!\n",i);
}
}
else
{
printf("Wrong!!\n",i);
}
}
return 0;
}
|
fakeid30/UVA-problems
|
Peter's smokes.c
|
<reponame>fakeid30/UVA-problems
#include<stdio.h>
int main()
{
int c,a,sum;
while(scanf("%d%d",&c,&a)!=EOF)
{
sum=c;
while(c>=a)
{
sum=sum+c/a;
c=c/a+c%a;
}
printf("%d\n",sum);
}
return 0;
}
|
fakeid30/UVA-problems
|
Lumberjack Sequencing.c
|
#include<stdio.h>
int main()
{
int n,array[10],i,d,a;
scanf("%d",&n);
printf("Lumberjacks:\n");
while(n--)
{
d=0;
a=0;
for(i=0;i<10;i++)
{
scanf("%d",&array[i]);
}
for(i=1;i<10;i++)
{
if(array[i-1]>=array[i])
{
d++;
}
else if(array[i-1]<=array[i])
{
a++;
}
}
if(d==9 || a==9)
{
printf("Ordered\n");
}
else
{
printf("Unordered\n");
}
}
return 0;
}
|
fakeid30/UVA-problems
|
Kindergarten counting game.c
|
<filename>Kindergarten counting game.c
#include<stdio.h>
#include<string.h>
int main()
{
char string[100000],c,i,l;
while(gets(string))
{
l=strlen(string);
c=0;
for(i=0;i<l;i++)
{
if(string[i]==32)
{
}
}
printf("%d\n",c+1);
}
return 0;
}
|
fakeid30/UVA-problems
|
Back to intermidiate math.c
|
#include<stdio.h>
#include<math.h>
int main()
{
int t,i;
double p,r,d,v,u;
scanf("%d",&t);
for(i=1;i<=t;i++)
{
scanf("%lf%lf%lf",&d,&v,&u);
p=d/u;
r=d/(sqrt(u*u-v*v));
if(v>=u || p==r)
{
printf("Case %d: can't determine\n",i);
continue;
}
printf("Case %d: %.3lf\n",i,r-p);
}
return 0;
}
|
fakeid30/UVA-problems
|
Feynman.c
|
#include<stdio.h>
int main()
{
int N,i,s;
while(scanf("%d",&N)!=EOF)
{
if(N==0)
{
break;
}
s=0;
for(i=1;i<=N;i++)
{
s=s+i*i;
}
printf("%d\n",s);
}
return 0;
}
|
fakeid30/UVA-problems
|
Average speed.c
|
<reponame>fakeid30/UVA-problems<filename>Average speed.c<gh_stars>1-10
#include<stdio.h>
#include<string.h>
int main()
{
char s[100000],s1[100000];
int i,l,l1,s=0,s1=0;
scanf("%[^\n]",s);
scanf("%[^\n]",s1);
l=strlen(l);
l1=strlen(l1);
for(i=0;i<l;i++)
{
if(s[i]=='|')
{
s=s+1
}
else if(s[i]=='n')
{
s=s+10;
}
else if(s[i]=='9')
{
s=s+100;
}
else if(s[i]=='8')
{
s=s+1000;
}
else if(s[i]=='r')
{
s=s+10000;
}
}
for(i=0;i<l1;i++)
{
if(s1[i]=='|')
{
s1=s1+1
}
else if(s1[i]=='n')
{
s1=s1+10;
}
else if(s1[i]=='9')
{
s1=s1+100;
}
else if(s1[i]=='8')
{
s1=s1+1000;
}
else if(s1[i]=='r')
{
s1=s1+10000;
}
}
s=s*s1;
if()
return 0;
}
|
fakeid30/UVA-problems
|
Power of cryptography.c
|
#include<stdio.h>
int main()
{
int n,i,j,k,array[10],t,g;
char string[12],st[12];
while(scanf("%d",&n))
{
for(i=0;i<n;i++)
{
scanf("%s ",&string[i]);
}
for(i=0;i<n;i++)
{
printf("%s %d\n",string[i],array[i]);
}
}
return 0;
}
|
fakeid30/UVA-problems
|
Three families.c
|
<gh_stars>1-10
#include<stdio.h>
int main()
{
int t;
float a,b,p,s;
scanf("%d",&t);
while(t--)
{
scanf("%f%f%f",&a,&b,&p);
s=0;
s=(a+b)/3;
a=a-s;
b=b-s;
s=a+b;
p=p/s;
printf("%.0f\n",a*p);
}
return 0;
}
|
fakeid30/UVA-problems
|
uva 113.c
|
#include<stdio.h>
int main()
{
unsigned long long p;
int n,k;
while(scanf("%d%llu",&n,&p)!=EOF)
{
k=0;
while(p!=1)
{
p=(float)p/n;
k++;
}
printf("%d\n",k);
}
return 0;
}
|
fakeid30/UVA-problems
|
Flag problem.c
|
<reponame>fakeid30/UVA-problems
#include<stdio.h>
int main()
{
int t,l;
float r,g;
scanf("%d",&t);
while(t--)
{
scanf("%d",&l);
r=3.1416*(l/5.0)*(l/5.0);
g=(l*((6*l)/10))-r;
printf("%.2f %.2f\n",r,g);
}
return 0;
}
|
fakeid30/UVA-problems
|
Language Detection.c
|
<gh_stars>1-10
#include<stdio.h>
int main()
{
char string[14];
int i=1;
while(scanf("%s",string)!=EOF && string[0]!='#')
{
if(string[0]=='H' && string[1]=='E' && string[2]=='L' && string[3]=='L' && string[4]=='O')
{
printf("Case %d: ENGLISH\n",i);
}
else if(string[0]=='H' && string[1]=='O' && string[2]=='L' && string[3]=='A')
{
printf("Case %d: SPANISH\n",i);
}
else if(string[0]=='H' && string[1]=='A' && string[2]=='L' && string[3]=='L' && string[4]=='O')
{
printf("Case %d: GERMAN\n",i);
}
else if(string[0]=='B' && string[1]=='O' && string[2]=='N' && string[3]=='J' && string[4]=='O' && string[5]=='U' && string[6]=='R')
{
printf("Case %d: FRENCH\n",i);
}
else if(string[0]=='C' && string[1]=='I' && string[2]=='A' && string[3]=='O')
{
printf("Case %d: ITALIAN\n",i);
}
else if(string[0]=='Z' && string[1]=='D' && string[2]=='R' && string[3]=='A' && string[4]=='V' && string[5]=='S' && string[6]=='T' && string[7]=='V' && string[8]=='U' && string[9]=='J' && string[10]=='T' && string[11]=='E')
{
printf("Case %d: RUSSIAN\n",i);
}
else
{
printf("Case %d: UNKNOWN\n",i);
}
i++;
}
return 0;
}
|
fakeid30/UVA-problems
|
Skew binary 575.c
|
#include<stdio.h>
#include<math.h>
#include<string.h>
int main()
{
char k[1000];
int i,n,s,c,l;
while(gets(k))
{
if(k[0]=='0')
{
break;
}
l=strlen(k);
s=0;
for(i=l-1,c=1;i>=0;i--,c++)
{
k[i]=k[i]-48;
s=s+k[i]*(pow(2,c)-1);
}
printf("%d\n",s);
}
return 0;
}
|
fakeid30/UVA-problems
|
Emoogle Balance.c
|
#include<stdio.h>
int main()
{
int n,array[100],i,c,c1,j=1;
while(1)
{
c=0;
c1=0;
scanf("%d",&n);
if(n==0)
{
break;
}
for(i=0;i<n;i++)
{
scanf("%d",&array[i]);
}
for(i=0;i<n;i++)
{
if(array[i]>0)
{
c++;
}
else
{
c1++;
}
}
printf("Case %d: %d\n",j,c-c1);
j++;
}
return 0;
}
|
fakeid30/UVA-problems
|
Save shetu.c
|
<reponame>fakeid30/UVA-problems<filename>Save shetu.c<gh_stars>1-10
#include<stdio.h>
int main()
{
int a=0,t,k,op1[6],op2[6];
scanf("%d",&t);
while(t--)
{
if(t%2!=0)
{
scanf("%s %d",&op1,&k);
a=a+k;
}
else
{
scanf("%s",&op2);
printf("%d\n",a);
}
}
return 0;
}
|
fakeid30/UVA-problems
|
Happy number.c
|
#include<stdio.h>
int main()
{
int a;
scanf("%d",&t);
for(i=1;i<=t;i++)
{
}
}
|
fakeid30/UVA-problems
|
Ugly numbers.c
|
#include<stdio.h>
int main()
{
int n,i=1,c=0;
while(c!=1500)
{
if(i%2==0 || i%3==0 || i%5==0)
{
c++;
}
i++;
}
printf("The 1500'th ugly number is %d.\n",i-1);
return 0;
}
|
fakeid30/UVA-problems
|
pizza cutting.c
|
#include<stdio.h>
int main()
{
long int N;
while(scanf("%ld",&N))
{
if(N<0)
{
break;
}
printf("%ld\n",N*(N+1)/2+1);
}
return 0;
}
|
fakeid30/UVA-problems
|
10302u.c
|
<gh_stars>1-10
#include<stdio.h>
int main()
{
int x;
unsigned long long int y;
while(scanf("%lld",&x)!=EOF)
{
y=0;
while(x)
{
y=y+x*x*x;
x--;
}
printf("%llu\n",y);
}
return 0;
}
|
fakeid30/UVA-problems
|
Anagram.c
|
#include<stdio.h>
#include<string.h>
int main()
{
int t,i,j,m,l;
char s[100000];
scanf("%d",&t);
while(t--)
{
scanf("%s",&s);
l=strlen(s);
for(i=0;i<l;i++)
{
for(j=i;j<l;j++)
{
if(s[i]>=s[j])
{
m=s[i];
s[i]=s[j];
s[j]=m;
}
}
}
}
return 0;
}
|
fakeid30/UVA-problems
|
Celebrity jeopardy.c
|
<gh_stars>1-10
#include<stdio.h>
int main()
{
char x[10000];
while(gets(x))
{
printf("%s\n",x);
}
return 0;
}
|
fakeid30/UVA-problems
|
Relational operator.c
|
<reponame>fakeid30/UVA-problems
#include<stdio.h>
int main()
{
int t,a,b,i;
scanf("%d",&t);
for(i=1;i<=t;i++)
{
scanf("%d%d",&a,&b);
if(a>b)
{
printf(">\n");
}
else if(a<b)
{
printf("<\n");
}
else
{
printf("=\n");
}
}
return 0;
}
|
fakeid30/UVA-problems
|
Bafana Bafana.c
|
#include<stdio.h>
int main()
{
int t,i,n,k,p,j;
scanf("%d",&t);
for(i=1;i<=t;i++)
{
scanf("%d%d%d",&n,&k,&p);
for(j=1;j<=p;j++)
{
if(k==n)
{
k=0;
}
k++;
}
printf("Case %d: %d\n",i,k);
}
return 0;
}
|
fakeid30/UVA-problems
|
How old are you.c
|
#include<stdio.h>
int main()
{
int t,i,d1,m1,y1,d2,m2,y2,age;
scanf("%d",&t);
for(i=1;i<=t;i++)
{
scanf("%d/%d/%d",&d1,&m1,&y1);
scanf("%d/%d/%d",&d2,&m2,&y2);
age=0;
age=y1-y2;
if(m2>m1)
{
age--;
}
else if(m2==m1)
{
if(d2>d1)
{
age--;
}
}
if(age<0)
{
printf("Case #%d: Invalid birth date\n",i);
}
else if(age>130)
{
printf("Case #%d: Check birth date\n",i);
}
else
{
printf("Case #%d: %d\n",i,age);
}
}
return 0;
}
|
fakeid30/UVA-problems
|
Joanna and the odd numbers.c
|
#include<stdio.h>
int main()
{
unsigned long long x,y;
int n,i;
while(scanf("%d",&n)!=EOF)
{
x=n;
y=n;
for(i=1;i<n;i++)
{
x=x+2;
y=y+x;
}
printf("%llu\n",y);
}
return 0;
}
|
fakeid30/UVA-problems
|
Big chocolate.c
|
<gh_stars>1-10
#include<stdio.h>
int main()
{
int m,n;
while(scanf("%d%d",&m,&n)!=EOF)
{
printf("%d\n",m-1+(n-1)*m);
}
return 0;
}
|
kaylabuki/internship-application-systems
|
pinger.c
|
<filename>pinger.c
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
int main(int argc, char** argv){
if(argc != 2){
fprintf(stderr, "Proper usage: pinger hostname | IP address");
}
char* hostname = argv[1];
char str_cmd[10 + strlen(hostname)];
strcpy(str_cmd, "ping -c 1 ");
strcat(str_cmd, hostname);
// char* output[1000];
while(1){
// Redirect system output to file
freopen("output.txt", "w", stdout);
system(str_cmd);
// Put file's contents into buffer
FILE *fp = fopen("output.txt", "rb");
fseek(fp, 0, SEEK_END);
long fsize = ftell(fp);
fseek(fp, 0, SEEK_SET);
char *data = malloc(fsize+1);
fread(data, 1, fsize, fp);
fclose(fp);
data[fsize] = 0;
// Extract desired data from buffer
char* time = strstr(data, "time=");
char* packet_loss = strstr(data, "received, ");
// fprintf(stderr, "%s\n", packet_loss);
if(time == NULL && packet_loss == NULL){
fprintf(stderr, "Cannot ping specified address\n");
exit(1);
}
char latency[100];
char pl[100];
// Process data
if(time != NULL){
int i = 0;
while(time[i+5] != '\n'){
latency[i] = time[i+5];
i++;
}
latency[i] = 0;
}
else{
strcpy(latency, "N/A");
}
if(packet_loss != NULL){
int i = 0;
while(packet_loss[i+10] != '%'){
pl[i] = packet_loss[i+10];
i++;
}
pl[i] = 0;
}
else{
strcpy(pl, "N/A");
}
// Reassign stdout and print data
freopen("/dev/tty", "w", stdout);
printf("Latency: %s\nPacket Loss: %s%%\n", latency, pl);
sleep(1);
}
}
|
Werkspot/php-stemmer
|
stemmer.c
|
<filename>stemmer.c
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "php_stemmer.h"
#include "libstemmer_c/include/libstemmer.h"
ZEND_BEGIN_ARG_INFO_EX(arginfo_void, 0, 0, 0)
ZEND_END_ARG_INFO()
static zend_function_entry stemmer_functions[] = {
PHP_FE(stemword, arginfo_void)
{NULL, NULL, NULL}
};
zend_module_entry stemmer_module_entry = {
#if ZEND_MODULE_API_NO >= 20010901
STANDARD_MODULE_HEADER,
#endif
PHP_STEMMER_EXTNAME,
stemmer_functions,
NULL,
NULL,
NULL,
NULL,
NULL,
#if ZEND_MODULE_API_NO >= 20010901
PHP_STEMMER_VERSION,
#endif
STANDARD_MODULE_PROPERTIES
};
#ifdef COMPILE_DL_STEMMER
ZEND_GET_MODULE(stemmer)
#endif
#if PHP_MAJOR_VERSION < 7
PHP_FUNCTION(stemword)
{
zval *lang, *enc, *arg;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzz", &arg,&lang,&enc) == FAILURE)RETURN_NULL();
convert_to_string(lang);
convert_to_string(enc);
struct sb_stemmer * stemmer;
//char * language = "kraaij_pohlmann";
//char * charenc = "UTF_8";
stemmer = sb_stemmer_new(Z_STRVAL_P(lang),Z_STRVAL_P(enc));
if(!stemmer) RETURN_NULL();
if(Z_TYPE_P(arg) == IS_ARRAY)
{
array_init(return_value);
HashTable *arr_hash;
HashPosition pointer;
int array_count;
arr_hash = Z_ARRVAL_P(arg);
array_count = zend_hash_num_elements(arr_hash);
zval **data;
for( zend_hash_internal_pointer_reset_ex(arr_hash,&pointer);
zend_hash_get_current_data_ex(arr_hash,(void **)&data, &pointer)==SUCCESS;
zend_hash_move_forward_ex(arr_hash,&pointer) ){
const sb_symbol *stemmed = "";
if(Z_TYPE_PP(data) == IS_STRING){
stemmed = sb_stemmer_stem(stemmer, Z_STRVAL_PP(data), Z_STRLEN_PP(data));
}
add_next_index_string(return_value,stemmed, 1);
}
}else{
convert_to_string(arg);
const sb_symbol *stemmed = sb_stemmer_stem(stemmer, Z_STRVAL_P(arg), Z_STRLEN_P(arg));
if(stemmed)ZVAL_STRING( return_value, stemmed, 1);
}
sb_stemmer_delete(stemmer);
// RETURN_STRING(stemmed, 1);
//return 1;
}
#else
PHP_FUNCTION(stemword)
{
zval *lang, *enc, *arg;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzz", &arg,&lang,&enc) == FAILURE)RETURN_NULL();
convert_to_string(lang);
convert_to_string(enc);
struct sb_stemmer * stemmer;
//char * language = "kraaij_pohlmann";
//char * charenc = "UTF_8";
stemmer = sb_stemmer_new(Z_STRVAL_P(lang),Z_STRVAL_P(enc));
if(!stemmer) RETURN_NULL();
if(Z_TYPE_P(arg) == IS_ARRAY)
{
array_init(return_value);
HashTable *arr_hash;
HashPosition pointer;
int array_count;
arr_hash = Z_ARRVAL_P(arg);
array_count = zend_hash_num_elements(arr_hash);
zval *data;
for( zend_hash_internal_pointer_reset_ex(arr_hash,&pointer);
zend_hash_get_current_data_ex(arr_hash,(void *)&data)==SUCCESS;
zend_hash_move_forward_ex(arr_hash,&pointer) ){
const sb_symbol *stemmed = "";
if(Z_TYPE_P(data) == IS_STRING){
stemmed = sb_stemmer_stem(stemmer, Z_STRVAL_P(data), Z_STRLEN_P(data));
}
add_next_index_string(return_value,stemmed);
}
}else{
convert_to_string(arg);
const sb_symbol *stemmed = sb_stemmer_stem(stemmer, Z_STRVAL_P(arg), Z_STRLEN_P(arg));
if(stemmed)ZVAL_STRING( return_value, stemmed);
}
sb_stemmer_delete(stemmer);
// RETURN_STRING(stemmed, 1);
//return 1;
}
#endif
|
Werkspot/php-stemmer
|
php_stemmer.h
|
#ifndef PHP_STEMMER_PHP_H
#define PHP_STEMMER_PHP_H 1
#define PHP_STEMMER_VERSION "1.0"
#define PHP_STEMMER_EXTNAME "stemmer"
PHP_FUNCTION(stemword);
extern zend_module_entry stemmer_module_entry;
#define phpext_stemmer_ptr &stemmer_module_entry
#endif
#ifndef TSRMLS_CC
#define TSRMLS_CC
#endif
|
symfund/lv_port_linux_frame_buffer
|
LVGL.DLL/LVGL_API.h
|
<gh_stars>1-10
#if !defined (__LVGL_API_H__)
#define __LVGL_API_H__
#ifdef __cplusplus
extern "C" {
#endif
#define CALLBACK __stdcall
# if defined (_WINDLL)
# define HMIAPI __declspec(dllexport)
# else
# define HMIAPI __declspec(dllimport)
# endif
HMIAPI int CALLBACK HMI_DllMain(void);
HMIAPI void CALLBACK HMI_SetLCDHandle(HWND);
HMIAPI int CALLBACK HMI_GetLCDWidth(void);
HMIAPI int CALLBACK HMI_GetLCDHeight(void);
HMIAPI int CALLBACK HMI_GetAppIcon(void);
#ifdef __cplusplus
}
#endif
#endif // __LVGL_API_H__
|
symfund/lv_port_linux_frame_buffer
|
LVGL.DLL/LVGL.DLL.c
|
#include "LVGL_API.h"
#include "../lvgl/lvgl.h"
#include <Windows.h>
#include <windowsx.h>
#include <VersionHelpers.h>
#include "resource.h"
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#ifndef WIN32DRV_MONITOR_ZOOM
#define WIN32DRV_MONITOR_ZOOM 1
#endif
//////////////////////////////////////////////////////////////////////////////
// LCD Dimension
// 16/9 1920/1080 1280/720 848/477
// 1024/600 768/450
// 16/10 768/480
static int g_lcd_width = 1024;
static int g_lcd_height = 600;
//////////////////////////////////////////////////////////////////////////////
// Framebuffer
HWND g_simulator_wndhandle;
HDC g_simulator_framebuffer_dc;
static uint32_t* g_pixel_buffer = NULL;
static size_t g_pixel_buffer_size = 0;
static bool volatile g_mouse_pressed = false;
static LPARAM volatile g_mouse_value = 0;
static bool volatile g_mousewheel_pressed = false;
static int16_t volatile g_mousewheel_value = 0;
static bool volatile g_keyboard_pressed = false;
static WPARAM volatile g_keyboard_value = 0;
HMIAPI int CALLBACK HMI_GetAppIcon(void)
{
return IDI_ICON_APPLICATION;
}
HMIAPI void CALLBACK HMI_SetLCDHandle(HWND wndHandle)
{
g_simulator_wndhandle = wndHandle;
}
HMIAPI int CALLBACK HMI_GetLCDWidth(void)
{
return g_lcd_width;
}
HMIAPI int CALLBACK HMI_GetLCDHeight(void)
{
return g_lcd_height;
}
HMIAPI int CALLBACK HMI_DllMain(void)
{
#ifndef SDL2
main(0, NULL);
#else
SDL2_main(0, NULL);
#endif
return 0;
}
///////////////////////////////////////////////////////////////////////////////
// SDL2 implementation
//
//#define SDL2
#define USE_MOUSE 1
#define USE_KEYBOARD 1
#define USE_MOUSEWHEEL 1
#ifdef SDL2
#include "SDL2/include/SDL.h"
#ifndef MONITOR_ZOOM
#define MONITOR_ZOOM 1
#endif
typedef struct
{
SDL_Window * window;
SDL_Renderer * renderer;
SDL_Texture * texture;
volatile bool sdl_refr_qry;
#if MONITOR_DOUBLE_BUFFERED
uint32_t * tft_fb_act;
#else
uint32_t * tft_fb;
#endif
} monitor_t;
monitor_t monitor;
static volatile bool sdl_inited = false;
static volatile bool sdl_quit_qry = false;
static bool left_button_down = false;
static int16_t last_x = 0;
static int16_t last_y = 0;
int quit_filter(void * userdata, SDL_Event * event)
{
(void)userdata;
if(event->type == SDL_WINDOWEVENT) {
if(event->window.event == SDL_WINDOWEVENT_CLOSE) {
sdl_quit_qry = true;
}
} else if(event->type == SDL_QUIT) {
sdl_quit_qry = true;
}
return 1;
}
static void monitor_sdl_clean_up(void)
{
SDL_DestroyTexture(monitor.texture);
SDL_DestroyRenderer(monitor.renderer);
SDL_DestroyWindow(monitor.window);
#if MONITOR_DUAL
SDL_DestroyTexture(monitor2.texture);
SDL_DestroyRenderer(monitor2.renderer);
SDL_DestroyWindow(monitor2.window);
#endif
SDL_Quit();
}
static void window_update(monitor_t * m)
{
#if MONITOR_DOUBLE_BUFFERED == 0
SDL_UpdateTexture(m->texture, NULL, m->tft_fb, g_lcd_width * sizeof(uint32_t));
#else
if(m->tft_fb_act == NULL) return;
SDL_UpdateTexture(m->texture, NULL, m->tft_fb_act, MONITOR_HOR_RES * sizeof(uint32_t));
#endif
SDL_RenderClear(m->renderer);
#if LV_COLOR_SCREEN_TRANSP
SDL_SetRenderDrawColor(m->renderer, 0xff, 0, 0, 0xff);
SDL_Rect r;
r.x = 0;
r.y = 0;
r.w = MONITOR_HOR_RES;
r.w = MONITOR_VER_RES;
SDL_RenderDrawRect(m->renderer, &r);
#endif
/*Update the renderer with the texture containing the rendered image*/
SDL_RenderCopy(m->renderer, m->texture, NULL, NULL);
SDL_RenderPresent(m->renderer);
}
static void monitor_sdl_refr(lv_timer_t * t)
{
(void)t;
/*Refresh handling*/
if(monitor.sdl_refr_qry != false) {
monitor.sdl_refr_qry = false;
window_update(&monitor);
}
#if MONITOR_DUAL
if(monitor2.sdl_refr_qry != false) {
monitor2.sdl_refr_qry = false;
window_update(&monitor2);
}
#endif
}
static void window_create(monitor_t * m)
{
#if 0
m->window =
SDL_CreateWindow("TFT Simulator", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, g_lcd_width * MONITOR_ZOOM,
g_lcd_height * MONITOR_ZOOM, 0); /*last param. SDL_WINDOW_BORDERLESS to hide borders*/
#else
m->window = SDL_CreateWindowFrom(g_simulator_wndhandle);
#endif
m->renderer = SDL_CreateRenderer(m->window, -1, SDL_RENDERER_SOFTWARE);
m->texture =
SDL_CreateTexture(m->renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STATIC, g_lcd_width, g_lcd_height);
SDL_SetTextureBlendMode(m->texture, SDL_BLENDMODE_BLEND);
/*Initialize the frame buffer to gray (77 is an empirical value) */
#if MONITOR_DOUBLE_BUFFERED
SDL_UpdateTexture(m->texture, NULL, m->tft_fb_act, MONITOR_HOR_RES * sizeof(uint32_t));
#else
m->tft_fb = (uint32_t *)malloc(sizeof(uint32_t) * g_lcd_width * g_lcd_height);
memset(m->tft_fb, 0x44, g_lcd_width * g_lcd_height * sizeof(uint32_t));
#endif
m->sdl_refr_qry = true;
}
static void monitor_sdl_init(void)
{
/*Initialize the SDL*/
SDL_Init(SDL_INIT_VIDEO);
SDL_SetEventFilter(quit_filter, NULL);
window_create(&monitor);
#if MONITOR_DUAL
window_create(&monitor2);
int x, y;
SDL_GetWindowPosition(monitor2.window, &x, &y);
SDL_SetWindowPosition(monitor.window, x + (MONITOR_HOR_RES * MONITOR_ZOOM) / 2 + 10, y);
SDL_SetWindowPosition(monitor2.window, x - (MONITOR_HOR_RES * MONITOR_ZOOM) / 2 - 10, y);
#endif
sdl_inited = true;
}
/// <summary>
/// Mousewheel implementation
/// </summary>
static int16_t enc_diff = 0;
static lv_indev_state_t state_mouse = LV_INDEV_STATE_RELEASED;
void mousewheel_init(void)
{
/*Nothing to init*/
}
void mousewheel_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
{
(void)indev_drv; /*Unused*/
data->state = state_mouse;
data->enc_diff = enc_diff;
enc_diff = 0;
}
void mousewheel_handler(SDL_Event * event)
{
switch(event->type) {
case SDL_MOUSEWHEEL:
// Scroll down (y = -1) means positive encoder turn,
// so invert it
#ifdef __EMSCRIPTEN__
/*Escripten scales it wrong*/
if(event->wheel.y < 0) enc_diff++;
if(event->wheel.y > 0) enc_diff--;
#else
enc_diff = -event->wheel.y;
#endif
break;
case SDL_MOUSEBUTTONDOWN:
if(event->button.button == SDL_BUTTON_MIDDLE) {
state_mouse = LV_INDEV_STATE_PRESSED;
}
break;
case SDL_MOUSEBUTTONUP:
if(event->button.button == SDL_BUTTON_MIDDLE) {
state_mouse = LV_INDEV_STATE_RELEASED;
}
break;
default: break;
}
}
void mouse_handler(SDL_Event * event)
{
switch(event->type) {
case SDL_MOUSEBUTTONUP:
if(event->button.button == SDL_BUTTON_LEFT) left_button_down = false;
break;
case SDL_MOUSEBUTTONDOWN:
if(event->button.button == SDL_BUTTON_LEFT) {
left_button_down = true;
last_x = event->motion.x / MONITOR_ZOOM;
last_y = event->motion.y / MONITOR_ZOOM;
}
break;
case SDL_MOUSEMOTION:
last_x = event->motion.x / MONITOR_ZOOM;
last_y = event->motion.y / MONITOR_ZOOM;
break;
case SDL_FINGERUP:
left_button_down = false;
last_x = LV_HOR_RES * event->tfinger.x / MONITOR_ZOOM;
last_y = LV_VER_RES * event->tfinger.y / MONITOR_ZOOM;
break;
case SDL_FINGERDOWN:
left_button_down = true;
last_x = LV_HOR_RES * event->tfinger.x / MONITOR_ZOOM;
last_y = LV_VER_RES * event->tfinger.y / MONITOR_ZOOM;
break;
case SDL_FINGERMOTION:
last_x = LV_HOR_RES * event->tfinger.x / MONITOR_ZOOM;
last_y = LV_VER_RES * event->tfinger.y / MONITOR_ZOOM;
break;
}
}
/// <summary>
/// Keyboard implementation
/// </summary>
static uint32_t last_key;
static lv_indev_state_t state_keyboard;
void keyboard_init(void)
{
/*Nothing to init*/
}
static uint32_t keycode_to_ascii(uint32_t sdl_key)
{
/*Remap some key to LV_KEY_... to manage groups*/
switch(sdl_key) {
case SDLK_RIGHT:
case SDLK_KP_PLUS: return LV_KEY_RIGHT;
case SDLK_LEFT:
case SDLK_KP_MINUS: return LV_KEY_LEFT;
case SDLK_UP: return LV_KEY_UP;
case SDLK_DOWN: return LV_KEY_DOWN;
case SDLK_ESCAPE: return LV_KEY_ESC;
#ifdef LV_KEY_BACKSPACE /*For backward compatibility*/
case SDLK_BACKSPACE: return LV_KEY_BACKSPACE;
#endif
#ifdef LV_KEY_DEL /*For backward compatibility*/
case SDLK_DELETE: return LV_KEY_DEL;
#endif
case SDLK_KP_ENTER:
case '\r': return LV_KEY_ENTER;
case SDLK_PAGEDOWN: return LV_KEY_NEXT;
case SDLK_PAGEUP: return LV_KEY_PREV;
default: return sdl_key;
}
}
void keyboard_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
{
(void)indev_drv; /*Unused*/
data->state = state_keyboard;
data->key = keycode_to_ascii(last_key);
}
void keyboard_handler(SDL_Event * event)
{
/* We only care about SDL_KEYDOWN and SDL_KEYUP events */
switch(event->type) {
case SDL_KEYDOWN: /*Button press*/
last_key = event->key.keysym.sym; /*Save the pressed key*/
state_keyboard = LV_INDEV_STATE_PRESSED; /*Save the key is pressed now*/
break;
case SDL_KEYUP: /*Button release*/
state_keyboard = LV_INDEV_STATE_RELEASED; /*Save the key is released but keep the last key*/
break;
default: break;
}
}
static void sdl_event_handler(lv_timer_t * t)
{
(void)t;
/*Refresh handling*/
SDL_Event event;
while(SDL_PollEvent(&event)) {
#if USE_MOUSE != 0
mouse_handler(&event);
#endif
#if USE_MOUSEWHEEL != 0
mousewheel_handler(&event);
#endif
#if USE_KEYBOARD
keyboard_handler(&event);
#endif
if((&event)->type == SDL_WINDOWEVENT) {
switch((&event)->window.event) {
#if SDL_VERSION_ATLEAST(2, 0, 5)
case SDL_WINDOWEVENT_TAKE_FOCUS:
#endif
case SDL_WINDOWEVENT_EXPOSED: window_update(&monitor);
#if MONITOR_DUAL
window_update(&monitor2);
#endif
break;
default: break;
}
}
}
/*Run until quit event not arrives*/
if(sdl_quit_qry) {
monitor_sdl_clean_up();
exit(0);
}
}
void monitor_init(void)
{
monitor_sdl_init();
lv_timer_create(sdl_event_handler, 10, NULL);
}
void monitor_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
{
lv_coord_t hres = disp_drv->hor_res;
lv_coord_t vres = disp_drv->ver_res;
// printf("x1:%d,y1:%d,x2:%d,y2:%d\n", area->x1, area->y1, area->x2, area->y2);
/*Return if the area is out the screen*/
if(area->x2 < 0 || area->y2 < 0 || area->x1 > hres - 1 || area->y1 > vres - 1) {
lv_disp_flush_ready(disp_drv);
return;
}
#if MONITOR_DOUBLE_BUFFERED
monitor.tft_fb_act = (uint32_t *)color_p;
#else /*MONITOR_DOUBLE_BUFFERED*/
int32_t y;
#if LV_COLOR_DEPTH != 24 && LV_COLOR_DEPTH != 32 /*32 is valid but support 24 for backward compatibility too*/
int32_t x;
for(y = area->y1; y <= area->y2 && y < disp_drv->ver_res; y++) {
for(x = area->x1; x <= area->x2; x++) {
monitor.tft_fb[y * disp_drv->hor_res + x] = lv_color_to32(*color_p);
color_p++;
}
}
#else
uint32_t w = lv_area_get_width(area);
for(y = area->y1; y <= area->y2 && y < disp_drv->ver_res; y++) {
memcpy(&monitor.tft_fb[y * g_lcd_width + area->x1], color_p, w * sizeof(lv_color_t));
color_p += w;
}
#endif
#endif /*MONITOR_DOUBLE_BUFFERED*/
monitor.sdl_refr_qry = true;
/* TYPICALLY YOU DO NOT NEED THIS
* If it was the last part to refresh update the texture of the window.*/
if(lv_disp_flush_is_last(disp_drv)) {
monitor_sdl_refr(NULL);
}
/*IMPORTANT! It must be called to tell the system the flush is ready*/
lv_disp_flush_ready(disp_drv);
}
static int tick_thread(void * data)
{
(void)data;
while(1) {
SDL_Delay(5);
lv_tick_inc(5); /*Tell LittelvGL that 5 milliseconds were elapsed*/
}
return 0;
}
void mouse_init(void)
{
}
void mouse_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
{
(void)indev_drv; /*Unused*/
/*Store the collected data*/
data->point.x = last_x;
data->point.y = last_y;
data->state = left_button_down ? LV_INDEV_STATE_PRESSED : LV_INDEV_STATE_RELEASED;
}
static void hal_init(void)
{
/* Use the 'monitor' driver which creates window on PC's monitor to simulate a display*/
monitor_init();
/* Tick init.
* You have to call 'lv_tick_inc()' in periodically to inform LittelvGL about
* how much time were elapsed Create an SDL thread to do this*/
SDL_CreateThread(tick_thread, "tick", NULL);
/*Create a display buffer*/
static lv_disp_draw_buf_t disp_buf1;
lv_color_t * buf1_1 = (lv_color_t *)malloc(sizeof(lv_color_t) * g_lcd_width * 120);
lv_color_t * buf1_2 = (lv_color_t *)malloc(sizeof(lv_color_t) * g_lcd_width * 120);
lv_disp_draw_buf_init(&disp_buf1, buf1_1, buf1_2, g_lcd_width * 100);
/*Create a display*/
static lv_disp_drv_t disp_drv;
lv_disp_drv_init(&disp_drv); /*Basic initialization*/
disp_drv.draw_buf = &disp_buf1;
disp_drv.flush_cb = monitor_flush;
disp_drv.hor_res = g_lcd_width;
disp_drv.ver_res = g_lcd_height;
disp_drv.antialiasing = 1;
lv_disp_t * disp = lv_disp_drv_register(&disp_drv);
lv_theme_t * th = lv_theme_default_init(disp, lv_palette_main(LV_PALETTE_BLUE), lv_palette_main(LV_PALETTE_RED),
LV_THEME_DEFAULT_DARK, LV_FONT_DEFAULT);
lv_disp_set_theme(disp, th);
lv_group_t * g = lv_group_create();
lv_group_set_default(g);
/* Add the mouse as input device
* Use the 'mouse' driver which reads the PC's mouse*/
mouse_init();
static lv_indev_drv_t indev_drv_1;
lv_indev_drv_init(&indev_drv_1); /*Basic initialization*/
indev_drv_1.type = LV_INDEV_TYPE_POINTER;
/*This function will be called periodically (by the library) to get the mouse position and state*/
indev_drv_1.read_cb = mouse_read;
lv_indev_t * mouse_indev = lv_indev_drv_register(&indev_drv_1);
keyboard_init();
static lv_indev_drv_t indev_drv_2;
lv_indev_drv_init(&indev_drv_2); /*Basic initialization*/
indev_drv_2.type = LV_INDEV_TYPE_KEYPAD;
indev_drv_2.read_cb = keyboard_read;
lv_indev_t * kb_indev = lv_indev_drv_register(&indev_drv_2);
lv_indev_set_group(kb_indev, g);
mousewheel_init();
static lv_indev_drv_t indev_drv_3;
lv_indev_drv_init(&indev_drv_3); /*Basic initialization*/
indev_drv_3.type = LV_INDEV_TYPE_ENCODER;
indev_drv_3.read_cb = mousewheel_read;
lv_indev_t * enc_indev = lv_indev_drv_register(&indev_drv_3);
lv_indev_set_group(enc_indev, g);
/*Set a cursor for the mouse*/
LV_IMG_DECLARE(mouse_cursor_icon); /*Declare the image file.*/
lv_obj_t * cursor_obj = lv_img_create(lv_scr_act()); /*Create an image object for the cursor */
lv_img_set_src(cursor_obj, &mouse_cursor_icon); /*Set the image source*/
lv_indev_set_cursor(mouse_indev, cursor_obj); /*Connect the image object to the driver*/
}
int SDL2_main(int argc, char ** argv)
{
(void)argc; /*Unused*/
(void)argv; /*Unused*/
/*Initialize LVGL*/
lv_init();
/*Initialize the HAL (display, input devices, tick) for LVGL*/
hal_init();
// lv_example_switch_1();
// lv_example_calendar_1();
// lv_example_btnmatrix_2();
// lv_example_checkbox_1();
// lv_example_colorwheel_1();
// lv_example_chart_6();
// lv_example_table_2();
// lv_example_scroll_2();
// lv_example_textarea_1();
// lv_example_msgbox_1();
// lv_example_dropdown_2();
// lv_example_btn_1();
// lv_example_scroll_1();
// lv_example_tabview_1();
// lv_example_tabview_1();
// lv_example_flex_3();
// lv_example_label_1();
lv_demo_widgets();
while(1) {
/* Periodically call the lv_task handler.
* It could be done in a timer interrupt or an OS task too.*/
lv_timer_handler();
// usleep(5 * 1000);
//Sleep(100);
//lv_task_handler();
}
return 0;
}
#endif
/// <summary>
/// WIN32 implementation
/// </summary>
static void lv_win32_display_driver_flush_callback(
lv_disp_drv_t* disp_drv,
const lv_area_t* area,
lv_color_t* color_p)
{
#if LV_COLOR_DEPTH == 32
UNREFERENCED_PARAMETER(area);
memcpy(g_pixel_buffer, color_p, g_pixel_buffer_size);
#else
for (int y = area->y1; y <= area->y2; ++y)
{
for (int x = area->x1; x <= area->x2; ++x)
{
g_pixel_buffer[y * disp_drv->hor_res + x] = lv_color_to32(*color_p);
color_p++;
}
}
#endif
HDC hWindowDC = GetDC(g_simulator_wndhandle);
if (hWindowDC)
{
StretchBlt(
hWindowDC,
0,
0,
disp_drv->hor_res * WIN32DRV_MONITOR_ZOOM,
disp_drv->ver_res * WIN32DRV_MONITOR_ZOOM,
g_simulator_framebuffer_dc,
0,
0,
disp_drv->hor_res,
disp_drv->ver_res,
SRCCOPY);
ReleaseDC(g_simulator_wndhandle, hWindowDC);
}
lv_disp_flush_ready(disp_drv);
}
static void lv_win32_display_driver_rounder_callback(
lv_disp_drv_t* disp_drv,
lv_area_t* area)
{
area->x1 = 0;
area->x2 = disp_drv->hor_res - 1;
area->y1 = 0;
area->y2 = disp_drv->ver_res - 1;
}
static void lv_win32_mouse_driver_read_callback(
lv_indev_drv_t* indev_drv,
lv_indev_data_t* data)
{
UNREFERENCED_PARAMETER(indev_drv);
data->state = (lv_indev_state_t)(
g_mouse_pressed ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL);
data->point.x = GET_X_LPARAM(g_mouse_value) / WIN32DRV_MONITOR_ZOOM;
data->point.y = GET_Y_LPARAM(g_mouse_value) / WIN32DRV_MONITOR_ZOOM;
}
static void lv_win32_keyboard_driver_read_callback(
lv_indev_drv_t* indev_drv,
lv_indev_data_t* data)
{
UNREFERENCED_PARAMETER(indev_drv);
data->state = (lv_indev_state_t)(
g_keyboard_pressed ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL);
WPARAM KeyboardValue = g_keyboard_value;
switch (KeyboardValue)
{
case VK_UP:
data->key = LV_KEY_UP;
break;
case VK_DOWN:
data->key = LV_KEY_DOWN;
break;
case VK_LEFT:
data->key = LV_KEY_LEFT;
break;
case VK_RIGHT:
data->key = LV_KEY_RIGHT;
break;
case VK_ESCAPE:
data->key = LV_KEY_ESC;
break;
case VK_DELETE:
data->key = LV_KEY_DEL;
break;
case VK_BACK:
data->key = LV_KEY_BACKSPACE;
break;
case VK_RETURN:
data->key = LV_KEY_ENTER;
break;
case VK_NEXT:
data->key = LV_KEY_NEXT;
break;
case VK_PRIOR:
data->key = LV_KEY_PREV;
break;
case VK_HOME:
data->key = LV_KEY_HOME;
break;
case VK_END:
data->key = LV_KEY_END;
break;
default:
if (KeyboardValue >= 'A' && KeyboardValue <= 'Z')
{
KeyboardValue += 0x20;
}
data->key = (uint32_t)KeyboardValue;
break;
}
}
static void lv_win32_mousewheel_driver_read_callback(
lv_indev_drv_t* indev_drv,
lv_indev_data_t* data)
{
UNREFERENCED_PARAMETER(indev_drv);
data->state = (lv_indev_state_t)(
g_mousewheel_pressed ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL);
data->enc_diff = g_mousewheel_value;
g_mousewheel_value = 0;
}
static HDC lv_win32_create_frame_buffer(
HWND WindowHandle,
LONG Width,
LONG Height,
UINT32** PixelBuffer,
SIZE_T* PixelBufferSize)
{
HDC hFrameBufferDC = NULL;
if (PixelBuffer && PixelBufferSize)
{
HDC hWindowDC = GetDC(WindowHandle);
if (hWindowDC)
{
hFrameBufferDC = CreateCompatibleDC(hWindowDC);
ReleaseDC(WindowHandle, hWindowDC);
}
if (hFrameBufferDC)
{
BITMAPINFO BitmapInfo = { 0 };
BitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
BitmapInfo.bmiHeader.biWidth = Width;
BitmapInfo.bmiHeader.biHeight = -Height;
BitmapInfo.bmiHeader.biPlanes = 1;
BitmapInfo.bmiHeader.biBitCount = 32;
BitmapInfo.bmiHeader.biCompression = BI_RGB;
HBITMAP hBitmap = CreateDIBSection(
hFrameBufferDC,
&BitmapInfo,
DIB_RGB_COLORS,
(void**)PixelBuffer,
NULL,
0);
if (hBitmap)
{
*PixelBufferSize = Width * Height * sizeof(UINT32);
DeleteObject(SelectObject(hFrameBufferDC, hBitmap));
DeleteObject(hBitmap);
}
else
{
DeleteDC(hFrameBufferDC);
hFrameBufferDC = NULL;
}
}
}
return hFrameBufferDC;
}
#define HIDE_CURSOR 0
#if HIDE_CURSOR
BOOL g_fMouseTracking = FALSE;
#endif
static LRESULT CALLBACK lv_win32_window_message_callback(
HWND hWnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
switch (uMsg)
{
#if HIDE_CURSOR
case WM_MOUSEHOVER:
{
if (!g_fMouseTracking)
{
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(TRACKMOUSEEVENT);
tme.dwFlags = TME_LEAVE;
tme.hwndTrack = hWnd;
g_fMouseTracking = TrackMouseEvent(&tme);
ShowCursor(FALSE);
}
}
break;
case WM_MOUSELEAVE:
{
g_fMouseTracking = FALSE;
ShowCursor(TRUE);
}
break;
#endif
case WM_MOUSEMOVE:
#if HIDE_CURSOR
if (!g_fMouseTracking) {
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(TRACKMOUSEEVENT);
tme.dwFlags = TME_LEAVE;
tme.hwndTrack = hWnd;
g_fMouseTracking = TrackMouseEvent(&tme);
ShowCursor(FALSE);
}
#endif
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
case WM_MBUTTONDOWN:
case WM_MBUTTONUP:
{
g_mouse_value = lParam;
if (uMsg == WM_LBUTTONDOWN || uMsg == WM_LBUTTONUP)
{
g_mouse_pressed = (uMsg == WM_LBUTTONDOWN);
}
else if (uMsg == WM_MBUTTONDOWN || uMsg == WM_MBUTTONUP)
{
g_mousewheel_pressed = (uMsg == WM_MBUTTONDOWN);
}
return 0;
}
case WM_KEYDOWN:
case WM_KEYUP:
{
g_keyboard_pressed = (uMsg == WM_KEYDOWN);
g_keyboard_value = wParam;
break;
}
case WM_MOUSEWHEEL:
{
g_mousewheel_value = -(GET_WHEEL_DELTA_WPARAM(wParam) / WHEEL_DELTA);
break;
}
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProcW(hWnd, uMsg, wParam, lParam);
}
return 0;
}
int main(int argc, char** argv)
{
lv_init();
WNDPROC prevWndProc = (WNDPROC)SetWindowLongPtr(g_simulator_wndhandle, GWLP_WNDPROC, (LONG_PTR)&lv_win32_window_message_callback);
g_simulator_framebuffer_dc = lv_win32_create_frame_buffer(
g_simulator_wndhandle,
g_lcd_width,
g_lcd_height,
&g_pixel_buffer,
&g_pixel_buffer_size);
#if LV_VERSION_CHECK(8, 0, 0)
static lv_disp_draw_buf_t disp_buf;
lv_disp_draw_buf_init(
&disp_buf,
(lv_color_t*)malloc(g_lcd_width * g_lcd_height * sizeof(lv_color_t)),
NULL,
g_lcd_width * g_lcd_height);
static lv_disp_drv_t disp_drv;
lv_disp_drv_init(&disp_drv);
disp_drv.hor_res = g_lcd_width;
disp_drv.ver_res = g_lcd_height;
disp_drv.flush_cb = lv_win32_display_driver_flush_callback;
disp_drv.draw_buf = &disp_buf;
disp_drv.rounder_cb = lv_win32_display_driver_rounder_callback;
lv_disp_drv_register(&disp_drv);
static lv_indev_drv_t indev_drv;
lv_indev_drv_init(&indev_drv);
indev_drv.type = LV_INDEV_TYPE_POINTER;
indev_drv.read_cb = lv_win32_mouse_driver_read_callback;
lv_indev_drv_register(&indev_drv);
static lv_indev_drv_t kb_drv;
lv_indev_drv_init(&kb_drv);
kb_drv.type = LV_INDEV_TYPE_KEYPAD;
kb_drv.read_cb = lv_win32_keyboard_driver_read_callback;
lv_indev_drv_register(&kb_drv);
static lv_indev_drv_t enc_drv;
lv_indev_drv_init(&enc_drv);
enc_drv.type = LV_INDEV_TYPE_ENCODER;
enc_drv.read_cb = lv_win32_mousewheel_driver_read_callback;
lv_indev_drv_register(&enc_drv);
#else
static lv_disp_buf_t disp_buf;
lv_disp_buf_init(
&disp_buf,
(lv_color_t*)malloc(hor_res * ver_res * sizeof(lv_color_t)),
NULL,
hor_res * ver_res);
lv_disp_drv_t disp_drv;
lv_disp_drv_init(&disp_drv);
disp_drv.hor_res = hor_res;
disp_drv.ver_res = ver_res;
disp_drv.flush_cb = lv_win32_display_driver_flush_callback;
disp_drv.buffer = &disp_buf;
disp_drv.rounder_cb = lv_win32_display_driver_rounder_callback;
g_display = lv_disp_drv_register(&disp_drv);
lv_indev_drv_t indev_drv;
lv_indev_drv_init(&indev_drv);
indev_drv.type = LV_INDEV_TYPE_POINTER;
indev_drv.read_cb = lv_win32_mouse_driver_read_callback;
lv_indev_drv_register(&indev_drv);
lv_indev_drv_t kb_drv;
lv_indev_drv_init(&kb_drv);
kb_drv.type = LV_INDEV_TYPE_KEYPAD;
kb_drv.read_cb = lv_win32_keyboard_driver_read_callback;
lv_indev_drv_register(&kb_drv);
lv_indev_drv_t enc_drv;
lv_indev_drv_init(&enc_drv);
enc_drv.type = LV_INDEV_TYPE_ENCODER;
enc_drv.read_cb = lv_win32_mousewheel_driver_read_callback;
lv_indev_drv_register(&enc_drv);
#endif
/*
* Demos, benchmarks, and tests.
*
* Uncomment any one (and only one) of the functions below to run that
* item.
*/
// ----------------------------------
// my application
// ----------------------------------
///*Init freetype library
// *Cache max 64 faces and 1 size*/
//lv_freetype_init(64, 1, 0);
///*Create a font*/
//static lv_ft_info_t info;
//info.name = "./lv_lib_freetype/arial.ttf";
//info.weight = 36;
//info.style = FT_FONT_STYLE_NORMAL;
//lv_ft_font_init(&info);
///*Create style with the new font*/
//static lv_style_t style;
//lv_style_init(&style);
//lv_style_set_text_font(&style, info.font);
///*Create a label with the new style*/
//lv_obj_t* label = lv_label_create(lv_scr_act());
//lv_obj_add_style(label, &style, 0);
//lv_label_set_text(label, "FreeType Arial Test");
// ----------------------------------
// Demos from lv_examples
// ----------------------------------
lv_demo_widgets(); // ok
// lv_demo_benchmark();
// lv_demo_keypad_encoder(); // ok
// lv_demo_music(); // removed from repository
// lv_demo_printer(); // removed from repository
// lv_demo_stress(); // ok
// ----------------------------------
// LVGL examples
// ----------------------------------
/*
* There are many examples of individual widgets found under the
* lvgl\exampless directory. Here are a few sample test functions.
* Look in that directory to find all the rest.
*/
// lv_ex_get_started_1();
// lv_ex_get_started_2();
// lv_ex_get_started_3();
// lv_example_flex_1();
// lv_example_flex_2();
// lv_example_flex_3();
// lv_example_flex_4();
// lv_example_flex_5();
// lv_example_flex_6(); // ok
// lv_example_grid_1();
// lv_example_grid_2();
// lv_example_grid_3();
// lv_example_grid_4();
// lv_example_grid_5();
// lv_example_grid_6();
// lv_port_disp_template();
// lv_port_fs_template();
// lv_port_indev_template();
// lv_example_scroll_1();
// lv_example_scroll_2();
// lv_example_scroll_3();
// lv_example_style_1();
// lv_example_style_2();
// lv_example_style_3();
// lv_example_style_4(); // ok
// lv_example_style_6(); // file has no source code
// lv_example_style_7();
// lv_example_style_8();
// lv_example_style_9();
// lv_example_style_10();
// lv_example_style_11(); // ok
// ----------------------------------
// LVGL widgets examples
// ----------------------------------
// lv_example_arc_1();
// lv_example_arc_2();
// lv_example_bar_1(); // ok
// lv_example_bar_2();
// lv_example_bar_3();
// lv_example_bar_4();
// lv_example_bar_5();
// lv_example_bar_6(); // issues
// lv_example_btn_1();
// lv_example_btn_2();
// lv_example_btn_3();
// lv_example_btnmatrix_1();
// lv_example_btnmatrix_2();
// lv_example_btnmatrix_3();
// lv_example_calendar_1();
// lv_example_canvas_1();
// lv_example_canvas_2();
// lv_example_chart_1(); // ok
// lv_example_chart_2(); // ok
// lv_example_chart_3(); // ok
// lv_example_chart_4(); // ok
// lv_example_chart_5(); // ok
// lv_example_chart_6(); // ok
// lv_example_checkbox_1();
// lv_example_colorwheel_1(); // ok
// lv_example_dropdown_1();
// lv_example_dropdown_2();
// lv_example_dropdown_3();
// lv_example_img_1();
// lv_example_img_2();
// lv_example_img_3();
// lv_example_img_4(); // ok
// lv_example_imgbtn_1();
// lv_example_keyboard_1(); // ok
// lv_example_label_1();
// lv_example_label_2(); // ok
// lv_example_led_1();
// lv_example_line_1();
// lv_example_list_1();
// lv_example_meter_1();
// lv_example_meter_2();
// lv_example_meter_3();
// lv_example_meter_4(); // ok
// lv_example_msgbox_1();
// lv_example_obj_1(); // ok
// lv_example_roller_1();
// lv_example_roller_2(); // ok
// lv_example_slider_1(); // ok
// lv_example_slider_2(); // issues
// lv_example_slider_3(); // issues
// lv_example_spinbox_1();
// lv_example_spinner_1(); // ok
// lv_example_switch_1(); // ok
// lv_example_table_1();
// lv_example_table_2(); // ok
// lv_example_tabview_1();
// lv_example_textarea_1(); // ok
// lv_example_textarea_2();
// lv_example_textarea_3(); // ok, but not all button have functions
// lv_example_tileview_1(); // ok
// lv_example_win_1(); // ok
// ----------------------------------
// Task handler loop
// ----------------------------------
while (1)
{
lv_task_handler();
}
return 0;
}
|
symfund/lv_port_linux_frame_buffer
|
lvgl/examples/assets/imgbtn_mid.c
|
<reponame>symfund/lv_port_linux_frame_buffer<filename>lvgl/examples/assets/imgbtn_mid.c
#if defined(LV_LVGL_H_INCLUDE_SIMPLE)
#include "lvgl.h"
#else
#include "../../lvgl.h"
#endif
#ifndef LV_ATTRIBUTE_MEM_ALIGN
#define LV_ATTRIBUTE_MEM_ALIGN
#endif
#ifndef LV_ATTRIBUTE_IMG_IMGBTN_MID
#define LV_ATTRIBUTE_IMG_IMGBTN_MID
#endif
const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_IMGBTN_MID uint8_t imgbtn_mid_map[] = {
#if LV_COLOR_DEPTH == 1 || LV_COLOR_DEPTH == 8
/*Pixel format: Blue: 2 bit, Green: 3 bit, Red: 3 bit, Alpha 8 bit */
0x68, 0x27, 0x68, 0x27, 0x68, 0x27, 0x68, 0x27, 0x68, 0x27,
0x64, 0xff, 0x64, 0xff, 0x64, 0xff, 0x64, 0xff, 0x64, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff,
0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff,
0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff,
0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff,
0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff,
0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff,
0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff,
0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff,
0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff,
0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff,
0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff,
0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff,
0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff,
0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff,
0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff,
0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff,
0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff,
0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff,
0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff,
0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff,
0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff,
0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff,
0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff,
0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff,
0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff,
0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff,
0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff,
0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff,
0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff,
0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff,
0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff,
0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff,
0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff,
0xf9, 0xff, 0xf9, 0xff, 0xf9, 0xff, 0xf9, 0xff, 0xf9, 0xff,
0x8c, 0xff, 0x8c, 0xff, 0x8c, 0xff, 0x8c, 0xff, 0x8c, 0xff,
0xac, 0xff, 0xac, 0xff, 0xac, 0xff, 0xac, 0xff, 0xac, 0xff,
0xac, 0xff, 0xac, 0xff, 0xac, 0xff, 0xac, 0xff, 0xac, 0xff,
0xac, 0xff, 0xac, 0xff, 0xac, 0xff, 0xac, 0xff, 0xac, 0xff,
0x44, 0xff, 0x44, 0xff, 0x44, 0xff, 0x44, 0xff, 0x44, 0xff,
0x44, 0xc0, 0x44, 0xc0, 0x44, 0xc0, 0x44, 0xc0, 0x44, 0xc0,
0x00, 0x57, 0x00, 0x57, 0x00, 0x57, 0x00, 0x57, 0x00, 0x57,
0x00, 0x58, 0x00, 0x58, 0x00, 0x58, 0x00, 0x58, 0x00, 0x58,
0x00, 0x54, 0x00, 0x54, 0x00, 0x54, 0x00, 0x54, 0x00, 0x54,
0x00, 0x2c, 0x00, 0x2c, 0x00, 0x2c, 0x00, 0x2c, 0x00, 0x2c,
0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04,
#endif
#if LV_COLOR_DEPTH == 16 && LV_COLOR_16_SWAP == 0
/*Pixel format: Blue: 5 bit, Green: 6 bit, Red: 5 bit, Alpha 8 bit*/
0xc0, 0x61, 0x27, 0xc0, 0x61, 0x27, 0xc0, 0x61, 0x27, 0xc0, 0x61, 0x27, 0xc0, 0x61, 0x27,
0x40, 0x51, 0xff, 0x40, 0x51, 0xff, 0x40, 0x51, 0xff, 0x40, 0x51, 0xff, 0x40, 0x51, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xf6, 0xf6, 0xff, 0xf6, 0xf6, 0xff, 0xf6, 0xf6, 0xff, 0xf6, 0xf6, 0xff, 0xf6, 0xf6, 0xff,
0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff,
0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff,
0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff,
0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff,
0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff,
0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff,
0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff,
0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff,
0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff,
0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff,
0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff,
0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff,
0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff,
0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff,
0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff,
0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff,
0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff,
0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff,
0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff,
0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff,
0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff,
0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff,
0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff,
0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff,
0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff,
0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff,
0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff,
0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff,
0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff,
0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff,
0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff,
0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff,
0x68, 0xe5, 0xff, 0x68, 0xe5, 0xff, 0x68, 0xe5, 0xff, 0x68, 0xe5, 0xff, 0x68, 0xe5, 0xff,
0x8a, 0xed, 0xff, 0x8a, 0xed, 0xff, 0x8a, 0xed, 0xff, 0x8a, 0xed, 0xff, 0x8a, 0xed, 0xff,
0xa1, 0x8a, 0xff, 0xa1, 0x8a, 0xff, 0xa1, 0x8a, 0xff, 0xa1, 0x8a, 0xff, 0xa1, 0x8a, 0xff,
0x43, 0x9b, 0xff, 0x43, 0x9b, 0xff, 0x43, 0x9b, 0xff, 0x43, 0x9b, 0xff, 0x43, 0x9b, 0xff,
0x43, 0x9b, 0xff, 0x43, 0x9b, 0xff, 0x43, 0x9b, 0xff, 0x43, 0x9b, 0xff, 0x43, 0x9b, 0xff,
0x83, 0xa3, 0xff, 0x83, 0xa3, 0xff, 0x83, 0xa3, 0xff, 0x83, 0xa3, 0xff, 0x83, 0xa3, 0xff,
0x20, 0x41, 0xff, 0x20, 0x41, 0xff, 0x20, 0x41, 0xff, 0x20, 0x41, 0xff, 0x20, 0x41, 0xff,
0xe0, 0x30, 0xc0, 0xe0, 0x30, 0xc0, 0xe0, 0x30, 0xc0, 0xe0, 0x30, 0xc0, 0xe0, 0x30, 0xc0,
0x00, 0x00, 0x57, 0x00, 0x00, 0x57, 0x00, 0x00, 0x57, 0x00, 0x00, 0x57, 0x00, 0x00, 0x57,
0x00, 0x00, 0x58, 0x00, 0x00, 0x58, 0x00, 0x00, 0x58, 0x00, 0x00, 0x58, 0x00, 0x00, 0x58,
0x00, 0x00, 0x54, 0x00, 0x00, 0x54, 0x00, 0x00, 0x54, 0x00, 0x00, 0x54, 0x00, 0x00, 0x54,
0x00, 0x00, 0x2c, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x2c,
0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x04,
#endif
#if LV_COLOR_DEPTH == 16 && LV_COLOR_16_SWAP != 0
/*Pixel format: Blue: 5 bit Green: 6 bit, Red: 5 bit, Alpha 8 bit BUT the 2 color bytes are swapped*/
0x61, 0xc0, 0x27, 0x61, 0xc0, 0x27, 0x61, 0xc0, 0x27, 0x61, 0xc0, 0x27, 0x61, 0xc0, 0x27,
0x51, 0x40, 0xff, 0x51, 0x40, 0xff, 0x51, 0x40, 0xff, 0x51, 0x40, 0xff, 0x51, 0x40, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xf6, 0xf6, 0xff, 0xf6, 0xf6, 0xff, 0xf6, 0xf6, 0xff, 0xf6, 0xf6, 0xff, 0xf6, 0xf6, 0xff,
0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff,
0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff,
0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff,
0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff,
0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff,
0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff,
0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff,
0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff,
0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff,
0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff,
0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff,
0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff,
0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff,
0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff,
0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff,
0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff,
0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff,
0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff,
0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff,
0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff,
0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff,
0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff,
0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff,
0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff,
0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff,
0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff,
0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff,
0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff,
0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff,
0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff,
0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff,
0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff,
0xe5, 0x68, 0xff, 0xe5, 0x68, 0xff, 0xe5, 0x68, 0xff, 0xe5, 0x68, 0xff, 0xe5, 0x68, 0xff,
0xed, 0x8a, 0xff, 0xed, 0x8a, 0xff, 0xed, 0x8a, 0xff, 0xed, 0x8a, 0xff, 0xed, 0x8a, 0xff,
0x8a, 0xa1, 0xff, 0x8a, 0xa1, 0xff, 0x8a, 0xa1, 0xff, 0x8a, 0xa1, 0xff, 0x8a, 0xa1, 0xff,
0x9b, 0x43, 0xff, 0x9b, 0x43, 0xff, 0x9b, 0x43, 0xff, 0x9b, 0x43, 0xff, 0x9b, 0x43, 0xff,
0x9b, 0x43, 0xff, 0x9b, 0x43, 0xff, 0x9b, 0x43, 0xff, 0x9b, 0x43, 0xff, 0x9b, 0x43, 0xff,
0xa3, 0x83, 0xff, 0xa3, 0x83, 0xff, 0xa3, 0x83, 0xff, 0xa3, 0x83, 0xff, 0xa3, 0x83, 0xff,
0x41, 0x20, 0xff, 0x41, 0x20, 0xff, 0x41, 0x20, 0xff, 0x41, 0x20, 0xff, 0x41, 0x20, 0xff,
0x30, 0xe0, 0xc0, 0x30, 0xe0, 0xc0, 0x30, 0xe0, 0xc0, 0x30, 0xe0, 0xc0, 0x30, 0xe0, 0xc0,
0x00, 0x00, 0x57, 0x00, 0x00, 0x57, 0x00, 0x00, 0x57, 0x00, 0x00, 0x57, 0x00, 0x00, 0x57,
0x00, 0x00, 0x58, 0x00, 0x00, 0x58, 0x00, 0x00, 0x58, 0x00, 0x00, 0x58, 0x00, 0x00, 0x58,
0x00, 0x00, 0x54, 0x00, 0x00, 0x54, 0x00, 0x00, 0x54, 0x00, 0x00, 0x54, 0x00, 0x00, 0x54,
0x00, 0x00, 0x2c, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x2c,
0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x04,
#endif
#if LV_COLOR_DEPTH == 32
/*Pixel format: Blue: 8 bit, Green: 8 bit, Red: 8 bit, Alpha: 8 bit*/
0x00, 0x38, 0x5f, 0x27, 0x00, 0x38, 0x5f, 0x27, 0x00, 0x38, 0x5f, 0x27, 0x00, 0x38, 0x5f, 0x27, 0x00, 0x38, 0x5f, 0x27,
0x00, 0x2a, 0x54, 0xff, 0x00, 0x2a, 0x54, 0xff, 0x00, 0x2a, 0x54, 0xff, 0x00, 0x2a, 0x54, 0xff, 0x00, 0x2a, 0x54, 0xff,
0xfd, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xaf, 0xdc, 0xf4, 0xff, 0xaf, 0xdc, 0xf4, 0xff, 0xaf, 0xdc, 0xf4, 0xff, 0xaf, 0xdc, 0xf4, 0xff, 0xaf, 0xdc, 0xf4, 0xff,
0x27, 0xa1, 0xe0, 0xff, 0x27, 0xa1, 0xe1, 0xff, 0x27, 0xa1, 0xe1, 0xff, 0x27, 0xa1, 0xe1, 0xff, 0x27, 0xa1, 0xe1, 0xff,
0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff,
0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff,
0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff,
0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff,
0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff,
0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff,
0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff,
0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff,
0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff,
0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff,
0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff,
0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff,
0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff,
0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff,
0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff,
0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff,
0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff,
0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff,
0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff,
0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff,
0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff,
0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff,
0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff,
0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff,
0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff,
0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff,
0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff,
0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff,
0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff,
0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff,
0x29, 0xa2, 0xe1, 0xff, 0x29, 0xa2, 0xe1, 0xff, 0x29, 0xa2, 0xe1, 0xff, 0x29, 0xa2, 0xe1, 0xff, 0x29, 0xa2, 0xe1, 0xff,
0x41, 0xac, 0xe4, 0xff, 0x41, 0xac, 0xe4, 0xff, 0x41, 0xac, 0xe4, 0xff, 0x41, 0xac, 0xe4, 0xff, 0x41, 0xac, 0xe4, 0xff,
0x4f, 0xb2, 0xe6, 0xff, 0x4f, 0xb2, 0xe6, 0xff, 0x4f, 0xb2, 0xe6, 0xff, 0x4f, 0xb2, 0xe6, 0xff, 0x4f, 0xb2, 0xe6, 0xff,
0x08, 0x56, 0x88, 0xff, 0x08, 0x56, 0x88, 0xff, 0x08, 0x56, 0x88, 0xff, 0x08, 0x56, 0x88, 0xff, 0x08, 0x56, 0x88, 0xff,
0x16, 0x68, 0x97, 0xff, 0x16, 0x68, 0x97, 0xff, 0x16, 0x68, 0x97, 0xff, 0x16, 0x68, 0x97, 0xff, 0x16, 0x68, 0x97, 0xff,
0x18, 0x6a, 0x98, 0xff, 0x18, 0x6a, 0x98, 0xff, 0x18, 0x6a, 0x98, 0xff, 0x18, 0x6a, 0x98, 0xff, 0x18, 0x6a, 0x98, 0xff,
0x19, 0x6f, 0x9e, 0xff, 0x1a, 0x6f, 0x9f, 0xff, 0x1a, 0x6f, 0x9e, 0xff, 0x1a, 0x6f, 0x9e, 0xff, 0x1a, 0x6f, 0x9e, 0xff,
0x00, 0x24, 0x3e, 0xff, 0x00, 0x24, 0x3e, 0xff, 0x00, 0x24, 0x3e, 0xff, 0x00, 0x24, 0x3e, 0xff, 0x00, 0x24, 0x3e, 0xff,
0x00, 0x1e, 0x33, 0xc0, 0x00, 0x1e, 0x33, 0xc0, 0x00, 0x1e, 0x33, 0xc0, 0x00, 0x1e, 0x33, 0xc0, 0x00, 0x1e, 0x33, 0xc0,
0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, 0x57,
0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x58,
0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x54,
0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x2c,
0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04,
#endif
};
const lv_img_dsc_t imgbtn_mid = {
.header.always_zero = 0,
.header.w = 5,
.header.h = 49,
.data_size = 245 * LV_IMG_PX_SIZE_ALPHA_BYTE,
.header.cf = LV_IMG_CF_TRUE_COLOR_ALPHA,
.data = imgbtn_mid_map,
};
|
marek-cel/fightersfs-tools
|
terrain_generator/src/gen/Types.h
|
<gh_stars>0
/****************************************************************************//*
* Copyright (C) 2020 <NAME>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
******************************************************************************/
#ifndef TYPES_H
#define TYPES_H
////////////////////////////////////////////////////////////////////////////////
#define TILE_MAX_LEVELS 3
#define TILE_MAX_COVER_TYPES 5
#define TILE_MAX_COAST_SQUARES_TYPES 10
#define TILE_MAX_COAST_ROWS_TYPES 2
#define TILE_MAX_COAST_COLS_TYPES 2
#define TILE_MAX_TREES_SQUARES_TYPES 10
#define TILE_MAX_TREES_ROWS_TYPES 2
#define TILE_MAX_TREES_COLS_TYPES 2
////////////////////////////////////////////////////////////////////////////////
enum Level
{
LevelH = 0,
LevelM = 1,
LevelL = 2
};
#if ( TILE_MAX_LEVELS != 3 )
# error 'TILE_MAX_LEVELS' has been changed! Check code above this line!
#endif
////////////////////////////////////////////////////////////////////////////////
enum CoverType
{
CoverWater = 0, ///< 0
CoverGrass, ///< 1
CoverCrops, ///< 2
CoverTrees, ///< 3
CoverUrban ///< 4
};
#if ( TILE_MAX_COVER_TYPES != 5 )
# error 'TILE_MAX_COVER_TYPES' has been changed! Check code above this line!
#endif
////////////////////////////////////////////////////////////////////////////////
enum CoastTypeSquares
{
Coast1NW = 0, ///< 0
Coast1NE, ///< 1
Coast1SE, ///< 2
Coast1SW, ///< 3
Coast3NW, ///< 4
Coast3NE, ///< 5
Coast3SE, ///< 6
Coast3SW, ///< 7
CoastNESW, ///< 8
CoastSENW ///< 9
};
#if ( TILE_MAX_COAST_SQUARES_TYPES != 10 )
# error 'TILE_MAX_COAST_SQUARES_TYPES' has been changed! Check code above this line!
#endif
////////////////////////////////////////////////////////////////////////////////
enum CoastTypeRows
{
CoastN = 0, ///< 0
CoastS ///< 1
};
#if ( TILE_MAX_COAST_ROWS_TYPES != 2 )
# error 'TILE_MAX_COAST_ROWS_TYPES' has been changed! Check code above this line!
#endif
////////////////////////////////////////////////////////////////////////////////
enum CoastTypeCols
{
CoastE = 0, ///< 0
CoastW, ///< 1
};
#if ( TILE_MAX_COAST_COLS_TYPES != 2 )
# error 'TILE_MAX_COAST_COLS_TYPES' has been changed! Check code above this line!
#endif
////////////////////////////////////////////////////////////////////////////////
enum TreesTypeSquares
{
Trees1NW = 0, ///< 0
Trees1NE, ///< 1
Trees1SE, ///< 2
Trees1SW, ///< 3
Trees3NW, ///< 4
Trees3NE, ///< 5
Trees3SE, ///< 6
Trees3SW, ///< 7
TreesNESW, ///< 8
TreesSENW ///< 9
};
#if ( TILE_MAX_TREES_SQUARES_TYPES != 10 )
# error 'TILE_MAX_TREES_SQUARES_TYPES' has been changed! Check code above this line!
#endif
////////////////////////////////////////////////////////////////////////////////
enum TreesTypeRows
{
TreesN = 0, ///< 0
TreesS ///< 1
};
#if ( TILE_MAX_TREES_ROWS_TYPES != 2 )
# error 'TILE_MAX_TREES_ROWS_TYPES' has been changed! Check code above this line!
#endif
////////////////////////////////////////////////////////////////////////////////
enum TreesTypeCols
{
TreesE = 0, ///< 0
TreesW, ///< 1
};
#if ( TILE_MAX_TREES_COLS_TYPES != 2 )
# error 'TILE_MAX_TREES_COLS_TYPES' has been changed! Check code above this line!
#endif
////////////////////////////////////////////////////////////////////////////////
#endif // TYPES_H
|
marek-cel/fightersfs-tools
|
missions_editor/src/editor/ObjectiveAltitude.h
|
/****************************************************************************//*
* Copyright (C) 2020 <NAME>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
******************************************************************************/
#ifndef OBJECTIVEALTITUDE_H
#define OBJECTIVEALTITUDE_H
////////////////////////////////////////////////////////////////////////////////
#include <editor/Objective.h>
////////////////////////////////////////////////////////////////////////////////
/** Altitude objective class. */
class ObjectiveAltitude : public Objective
{
public:
/**
* Reads objective from XML file.
* @param xmlNode objective XML node
* @return returns objective object on success and null on failure
*/
static ObjectiveAltitude* readObjective( QDomElement &xmlNode );
/** */
ObjectiveAltitude();
Objective* clone();
/**
* Saves objective to XML file.
* @param doc XML document
* @param parentNode XML parent node
*/
void saveObjective( QDomDocument &doc, QDomElement &parentNode );
/** */
const char* getTypeName() { return "Altitude"; }
inline float getAbove() const { return m_above; }
inline float getBelow() const { return m_below; }
inline void setAbove( float val ) { m_above = val; }
inline void setBelow( float val ) { m_below = val; }
private:
float m_above;
float m_below;
};
////////////////////////////////////////////////////////////////////////////////
#endif // OBJECTIVEALTITUDE_H
|
marek-cel/fightersfs-tools
|
terrain_generator/src/gen/Geo.h
|
/****************************************************************************//*
* Copyright (C) 2020 <NAME>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
******************************************************************************/
#ifndef GEO_H
#define GEO_H
////////////////////////////////////////////////////////////////////////////////
#include <osg/Math>
////////////////////////////////////////////////////////////////////////////////
class Geo
{
public:
Geo();
Geo( const Geo &geo );
Geo( double origLat, double origLon, double scale );
inline double d2r( double d ) { return osg::DegreesToRadians( d ); }
inline double r2d( double r ) { return osg::RadiansToDegrees( r ); }
double lat_d2m( double d );
double lat_m2d( double m );
double lon_d2m( double d );
double lon_m2d( double m );
inline double lat_m2r( double m ) { return d2r( lat_m2d( m ) ); }
inline double lat_r2m( double r ) { return lat_d2m( r2d( r ) ); }
inline double lon_m2r( double m ) { return d2r( lon_m2d( m ) ); }
inline double lon_r2m( double r ) { return lon_d2m( r2d( r ) ); }
void cart2geo( double x, double y, double &lat, double &lon );
inline double getOrigLat() const { return m_origLat; }
inline double getOrigLon() const { return m_origLon; }
inline double getScale() const { return m_scale; }
inline void setOrigLat( double origLat ) { m_origLat = origLat; update(); }
inline void setOrigLon( double origLon ) { m_origLon = origLon; update(); }
inline void setScale( double scale ) { m_scale = scale; update(); }
private:
double m_scale;
double m_origLat;
double m_origLon;
double m_lat_d2m;
double m_lon_d2m;
void update();
};
////////////////////////////////////////////////////////////////////////////////
#endif // GEO_H
|
marek-cel/fightersfs-tools
|
missions_editor/src/gui/MainWindow.h
|
<filename>missions_editor/src/gui/MainWindow.h
/****************************************************************************//*
* Copyright (C) 2020 <NAME>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
******************************************************************************/
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
////////////////////////////////////////////////////////////////////////////////
#include <QMainWindow>
#include <QSettings>
#include <QShortcut>
#include "RecentFileAction.h"
////////////////////////////////////////////////////////////////////////////////
namespace Ui
{
class MainWindow;
}
////////////////////////////////////////////////////////////////////////////////
/** Main window class. */
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
/** Constructor. */
explicit MainWindow(QWidget *parent = 0);
/** Destructor. */
virtual ~MainWindow();
protected:
/** */
void closeEvent( QCloseEvent *event );
/** */
void keyPressEvent( QKeyEvent *event );
/** */
void timerEvent( QTimerEvent *event );
private:
Ui::MainWindow *m_ui; ///<
QShortcut *m_shortcutSave;
bool m_saved; ///<
int m_timerId; ///<
QString m_currentFile; ///<
QStringList m_recentFilesList; ///<
std::vector< RecentFileAction* > m_recentFilesActions;
void askIfSave();
void newFile();
void openFile();
void saveFile();
void saveFileAs();
void readFile( QString fileName );
void saveFile( QString fileName );
void settingsRead();
void settingsRead_RecentFiles( QSettings &settings );
void settingsSave();
void settingsSave_RecentFiles( QSettings &settings );
void updateGUI();
void updateRecentFiles( QString file = "" );
public slots:
void on_widgetDoc_changed();
void on_widgetDoc_sceneryReloaded();
void recentFile_triggered( int id );
private slots:
void on_actionNew_triggered();
void on_actionOpen_triggered();
void on_actionClearRecent_triggered();
void on_actionSave_triggered();
void on_actionSaveAs_triggered();
void on_actionExit_triggered();
void on_actionViewOrbit_triggered();
void on_actionViewWorld_triggered();
};
////////////////////////////////////////////////////////////////////////////////
#endif // MAINWINDOW_H
|
marek-cel/fightersfs-tools
|
missions_editor/src/Languages.h
|
<gh_stars>0
/****************************************************************************//*
* Copyright (C) 2020 <NAME>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
******************************************************************************/
#ifndef LANGUAGES_H
#define LANGUAGES_H
////////////////////////////////////////////////////////////////////////////////
#include <QString>
#include <QVector>
////////////////////////////////////////////////////////////////////////////////
/** */
class Languages
{
public:
typedef QVector< QString > List;
inline static Languages* instance()
{
if ( !m_instance )
{
m_instance = new Languages();
}
return m_instance;
}
private:
/** Default constructor. */
Languages();
/** Copy constructor. */
Languages( const Languages & ) {}
public:
/** Destructor. */
virtual ~Languages();
/** */
inline int getCurrent() const { return m_current; }
/** */
inline int getDefault() const { return m_default; }
/** */
QString getCodeByIndex( int index ) const;
/** */
int getIndexByCode( const QString &code ) const;
/** */
inline int getCount() const { return m_list.size(); }
/** */
void setCurrent( int current );
private:
static Languages *m_instance;
List m_list; ///< supported languages list
int m_current; ///< current language index
int m_default; ///< default language index
void readLanguages();
};
////////////////////////////////////////////////////////////////////////////////
#endif // LANGUAGES_H
|
marek-cel/fightersfs-tools
|
missions_editor/src/gui/WidgetEditUnit.h
|
<gh_stars>0
/****************************************************************************//*
* Copyright (C) 2020 <NAME>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
******************************************************************************/
#ifndef WIDGETEDITUNIT_H
#define WIDGETEDITUNIT_H
////////////////////////////////////////////////////////////////////////////////
#include <QWidget>
#include <editor/Mission.h>
#include <cgi/SceneRoot.h>
////////////////////////////////////////////////////////////////////////////////
namespace Ui
{
class WidgetEditUnit;
}
////////////////////////////////////////////////////////////////////////////////
/** Unit editing widget class. */
class WidgetEditUnit : public QWidget
{
Q_OBJECT
public:
/** Constructor. */
explicit WidgetEditUnit( QWidget *parent = 0 );
/** Destructor. */
~WidgetEditUnit();
void edit( int unitIndex );
signals:
void changed();
void done();
private:
Ui::WidgetEditUnit *m_ui;
bool m_inited;
int m_unitIndex;
Unit *m_unit;
void updateGUI();
private slots:
void on_lineEditUnitName_editingFinished();
void on_radioButtonFriend_toggled(bool checked);
void on_radioButtonHostile_toggled(bool checked);
void on_radioButtonNeutral_toggled(bool checked);
void on_comboBoxUnitType_currentIndexChanged(int index);
void on_lineEditUnitFile_textChanged(const QString &arg1);
void on_pushButtonUnitFile_clicked();
void on_spinBoxUnitHP_valueChanged(int arg1);
void on_lineEditUnitLivery_textChanged(const QString &arg1);
void on_pushButtonUnitLivery_clicked();
void on_checkBoxUnique_toggled(bool checked);
void on_checkBoxWingman_toggled(bool checked);
void on_comboBoxLeader_currentIndexChanged(int index);
void on_spinBoxLeaderX_editingFinished();
void on_spinBoxLeaderY_editingFinished();
void on_spinBoxLeaderZ_editingFinished();
void on_checkBoxUnitRoute_toggled(bool checked);
void on_comboBoxUnitRoute_currentIndexChanged(int index);
void on_spinBoxUnitPositionX_editingFinished();
void on_spinBoxUnitPositionY_editingFinished();
void on_spinBoxUnitPositionZ_editingFinished();
void on_spinBoxUnitPositionZ_valueChanged(double arg1);
void on_spinBoxUnitSpeed_editingFinished();
void on_spinBoxUnitSpeed_valueChanged(double arg1);
void on_spinBoxUnitHeading_editingFinished();
void on_checkBoxOwnship_toggled(bool checked);
void on_pushButtonDone_clicked();
};
////////////////////////////////////////////////////////////////////////////////
#endif // WIDGETEDITUNIT_H
|
marek-cel/fightersfs-tools
|
missions_editor/src/editor/Unit.h
|
/****************************************************************************//*
* Copyright (C) 2020 <NAME>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
******************************************************************************/
#ifndef UNIT_H
#define UNIT_H
////////////////////////////////////////////////////////////////////////////////
#include <osg/Quat>
#include <osg/Vec3d>
#include <QDomDocument>
#include <QDomElement>
////////////////////////////////////////////////////////////////////////////////
/** Unit class. */
class Unit
{
public:
enum Affiliation
{
Friend = 0x1, ///< friend
Hostile = 0x2, ///< hostile
Neutral = 0x3 ///< neutral
};
enum Type
{
Unknown = 0x0, ///<
Aircraft, ///<
Balloon, ///<
BomberDive, ///<
BomberLevel, ///<
BomberTorpedo, ///<
Building, ///<
Fighter, ///<
Kamikaze, ///<
Warship, ///<
Maximum ///<
};
static Type nameToType( const QString &name );
static std::string typeToName( Type type );
static bool isAircraft( Type type );
/**
* Reads unit from XML file.
* @param xmlNode unit XML node
* @return returns unit object on success and null on failure
*/
static Unit* readUnit( QDomElement &xmlNode, Affiliation affiliation );
/** Constructor. */
Unit();
/** Destructor. */
virtual ~Unit();
bool isOwnship() const { return m_ownship; }
/**
* Saves unit to XML file.
* @param doc XML document
* @param parentNode XML parent node
*/
void saveUnit( QDomDocument &doc, QDomElement &parentNode );
inline Affiliation getAffiliation() const { return m_affiliation; }
inline Type getType() const { return m_type; }
inline std::string getName() const { return m_name; }
inline std::string getRoute() const { return m_route; }
inline std::string getFile() const { return m_file; }
inline std::string getModel() const { return m_model; }
inline osg::Vec3d getPosition() const { return m_position; }
inline osg::Quat getAttitude() const { return m_attitude; }
inline std::string getLeader() const { return m_leader; }
inline osg::Vec3d getOffset() const { return m_offset; }
inline std::string getLivery() const { return m_livery; }
inline double getHeading() const { return m_heading; }
inline double getVelocity() const { return m_velocity; }
inline int getHP() const { return m_hp; }
inline bool getUnique() const { return m_unique; }
inline bool getWingman() const { return m_wingman; }
void setAffiliation( Affiliation affiliation ) { m_affiliation = affiliation; }
void setType( Type type ) { m_type = type; }
void setName( const std::string &name ) { m_name = name; }
void setRoute( const std::string &route ) { m_route = route; }
void setFile( const std::string &file );
void setPosition( osg::Vec3d position ) { m_position = position; }
void setLeader( const std::string &leader ) { m_leader = leader; }
void setOffset( const osg::Vec3d &offset ) { m_offset = offset; }
void setLivery( const std::string &livery ) { m_livery = livery; }
void setHeading( double heading );
void setVelocity( double velocity ) { m_velocity = velocity; }
void setUnique( bool unique ) { m_unique = unique; }
void setWingman( bool wingman ) { m_wingman = wingman; }
void setOwnship( bool ownship );
void setHP( int hp );
private:
Affiliation m_affiliation; ///< unit affiliation
Type m_type; ///< unit type
std::string m_name; ///< unit name
std::string m_route; ///< name of route (aircraft only)
std::string m_file; ///< unit file path
std::string m_model; ///< unit model file path
osg::Vec3d m_position; ///< [m] initial position expressed in East-North-Up coordinate system
osg::Quat m_attitude; ///< initial attitude expressed as a quaternion
std::string m_leader; ///< name of a formation leader (aircraft only)
std::string m_livery; ///< livery file path
osg::Vec3d m_offset; ///< [m] offset to formation leader (aircraft only)
double m_heading; ///< [deg] initial heading
double m_velocity; ///< [kts] initial velocity
bool m_ownship; ///< specifies if unit is an ownship
bool m_unique; ///< specifies in unit is unique
bool m_wingman; ///< specifies if unit is a wingman
int m_hp; ///< hit points
};
////////////////////////////////////////////////////////////////////////////////
#endif // UNIT_H
|
marek-cel/fightersfs-tools
|
missions_editor/src/editor/Message.h
|
<reponame>marek-cel/fightersfs-tools
/****************************************************************************//*
* Copyright (C) 2020 <NAME>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
******************************************************************************/
#ifndef MESSAGE_H
#define MESSAGE_H
////////////////////////////////////////////////////////////////////////////////
#include <vector>
#include <QDomDocument>
#include <QDomElement>
#include "Text.h"
////////////////////////////////////////////////////////////////////////////////
/** Stage message class. */
class Message
{
public:
typedef std::vector< Text > Lines;
/**
* Reads message from XML file.
* @param xmlNode message XML node
* @return returns message object on success and null on failure
*/
static Message* readMessage( QDomElement &xmlNode );
/** Constructor. */
Message();
/** Destructor. */
virtual ~Message();
/**
* Saves message to XML file.
* @param doc XML document
* @param parentNode XML parent node
*/
void saveMessage( QDomDocument &doc, QDomElement &parentNode );
inline bool getOverlay() const { return m_overlay; }
inline double getDuration() const { return m_duration; }
inline double getDelay() const { return m_delay; }
inline Lines getLines() const { return m_lines; }
inline bool getPointerCustom() const { return m_pointer_custom; }
inline bool getPointerTarget() const { return m_pointer_target; }
inline bool getPointerRpmDec() const { return m_pointer_rpm_dec; }
inline bool getPointerRpmInc() const { return m_pointer_rpm_inc; }
inline bool getPointerTrigger() const { return m_pointer_trigger; }
inline double getPointerX() const { return m_pointer_x; }
inline double getPointerY() const { return m_pointer_y; }
inline double getPointerPhi() const { return m_pointer_phi; }
inline int getTutorialTip() const { return m_tutorial_tip; }
inline void setOverlay( bool overlay ) { m_overlay = overlay; }
inline void setDuration( double duration ) { m_duration = duration; }
inline void setDelay( double delay ) { m_delay = delay; }
inline void setLines( const Lines &lines ) { m_lines = lines; }
inline void setPointerCustom( bool val ) { m_pointer_custom = val; }
inline void setPointerTarget( bool val ) { m_pointer_target = val; }
inline void setPointerRpmDec( bool val ) { m_pointer_rpm_dec = val; }
inline void setPointerRpmInc( bool val ) { m_pointer_rpm_inc = val; }
inline void setPointerTrigger( bool val ) { m_pointer_trigger = val; }
inline void setPointerX( double val ) { m_pointer_x = val; }
inline void setPointerY( double val ) { m_pointer_y = val; }
inline void setPointerPhi( double val ) { m_pointer_phi = val; }
inline void setTutorialTip( int val ) { m_tutorial_tip = val; }
private:
bool m_overlay;
double m_duration; ///< [s]
double m_delay; ///< [s]
Lines m_lines;
bool m_pointer_custom;
bool m_pointer_target;
bool m_pointer_rpm_dec; ///< specifies if decrease RPM pointer is visible
bool m_pointer_rpm_inc; ///< specifies if increase RPM pointer is visible
bool m_pointer_trigger; ///< specifies if trigger pointer is visible
double m_pointer_x;
double m_pointer_y;
double m_pointer_phi;
int m_tutorial_tip;
};
////////////////////////////////////////////////////////////////////////////////
#endif // MESSAGE_H
|
marek-cel/fightersfs-tools
|
terrain_generator/src/gui/GraphicsWindowQt.h
|
<filename>terrain_generator/src/gui/GraphicsWindowQt.h
/****************************************************************************//*
* Copyright (C) 2020 <NAME>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
******************************************************************************/
#ifndef GRAPHICSWINDOWQT_H
#define GRAPHICSWINDOWQT_H
////////////////////////////////////////////////////////////////////////////////
#include <osgViewer/GraphicsWindow>
#include <QEvent>
#include <QGLWidget>
#include <QInputEvent>
#include <QMutex>
#include <QQueue>
#include <QSet>
////////////////////////////////////////////////////////////////////////////////
class GraphicsWindowQt : public osgViewer::GraphicsWindow
{
class GLWidget;
friend class GLWidget;
public:
struct WinData : public osg::Referenced
{
WinData( GLWidget *widget = 0, QWidget *parent = 0 ) :
_widget ( widget ),
_parent ( parent )
{}
GLWidget *_widget; ///<
QWidget *_parent; ///<
};
/**
* Constructor.
* @param traits
*/
GraphicsWindowQt( osg::GraphicsContext::Traits *traits );
/** Destructor. */
virtual ~GraphicsWindowQt();
virtual bool setWindowRectangleImplementation( int x, int y, int w, int h );
virtual void getWindowRectangle( int &x, int &y, int &w, int &h );
virtual void grabFocus();
virtual void grabFocusIfPointerInWindow();
virtual void raiseWindow();
virtual void useCursor( bool cursorOn );
virtual void setCursor( MouseCursor cursor );
virtual bool valid() const;
virtual bool realizeImplementation();
virtual bool isRealizedImplementation() const;
virtual void closeImplementation();
virtual bool makeCurrentImplementation();
virtual bool releaseContextImplementation();
virtual void swapBuffersImplementation();
virtual void runOperations();
virtual void requestWarpPointer( float x, float y );
inline GLWidget* getGLWidget() { return _widget; }
inline const GLWidget* getGLWidget() const { return _widget; }
private:
class GLWidget : public QGLWidget
{
friend class GraphicsWindowQt;
public:
GLWidget( const QGLFormat &format,
QWidget *parent = 0, const QGLWidget *shareWidget = 0,
Qt::WindowFlags flags = 0 );
virtual ~GLWidget();
inline GraphicsWindowQt* getGraphicsWindow() { return _gwin; }
inline const GraphicsWindowQt* getGraphicsWindow() const { return _gwin; }
inline void setGraphicsWindow( GraphicsWindowQt *gwin ) { _gwin = gwin; }
void setKeyboardModifiers( QInputEvent *event );
protected:
virtual bool event( QEvent *event );
virtual void keyPressEvent ( QKeyEvent *event );
virtual void keyReleaseEvent ( QKeyEvent *event );
virtual void mousePressEvent ( QMouseEvent *event );
virtual void mouseReleaseEvent ( QMouseEvent *event );
virtual void mouseDoubleClickEvent ( QMouseEvent *event );
virtual void mouseMoveEvent ( QMouseEvent *event );
virtual void moveEvent( QMoveEvent *event );
virtual void resizeEvent( QResizeEvent *event );
virtual void wheelEvent( QWheelEvent *event );
virtual void glDraw();
private:
GraphicsWindowQt *_gwin; ///<
QMutex _deferredEventQueueMutex; ///<
QQueue < QEvent::Type > _deferredEventQueue; ///<
QSet < QEvent::Type > _eventCompressor; ///<
int getNumDeferredEvents();
void enqueueDeferredEvent( QEvent::Type eventType,
QEvent::Type removeEventType = QEvent::None );
void processDeferredEvents();
};
GLWidget *_widget; ///<
QCursor _currentCursor; ///<
bool _ownsWidget; ///<
bool _realized; ///<
};
////////////////////////////////////////////////////////////////////////////////
#endif // GRAPHICSWINDOWQT_H
|
marek-cel/fightersfs-tools
|
missions_editor/src/cgi/SceneRoot.h
|
/****************************************************************************//*
* Copyright (C) 2020 <NAME>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
******************************************************************************/
#ifndef SCENEROOT_H
#define SCENEROOT_H
////////////////////////////////////////////////////////////////////////////////
#include <osg/Group>
#include <osg/Material>
#include <osg/PositionAttitudeTransform>
#include <osg/Switch>
#include <editor/Singleton.h>
#include <cgi/Camera.h>
#include <cgi/Routes.h>
#include <cgi/Scenery.h>
#include <cgi/Units.h>
////////////////////////////////////////////////////////////////////////////////
/** Scene root class. */
class SceneRoot : public Singleton< SceneRoot >
{
friend class Singleton< SceneRoot >;
private:
/** Constructor. */
SceneRoot();
public:
/** Destructor. */
virtual ~SceneRoot();
inline osgGA::CameraManipulator* getManipulator() { return m_camera->getManipulator(); }
void reloadRoutes();
void reloadScenery();
void reloadUnits();
void hideAll();
void hideMarker();
void showMarker( osg::Vec3d position );
void hideRoute();
void showRoute( int routeIndex );
void hideUnit();
void showUnit( int unitIndex );
void update();
void setViewOrbit();
void setViewWorld();
/** Returns root node. */
inline osg::ref_ptr<osg::Group> getNode() { return m_root; }
private:
osg::ref_ptr<osg::Group> m_root; ///< root group
Camera *m_camera;
Routes *m_routes;
Scenery *m_scenery;
Units *m_units;
osg::ref_ptr<osg::Group> m_groupRoute; ///< route group
osg::Vec3d m_position; ///< marker position
osg::ref_ptr<osg::PositionAttitudeTransform> m_patMarker;
osg::ref_ptr<osg::Switch> m_switchMarker;
void createMarker();
void createSceneLight();
void loadTerrain();
};
////////////////////////////////////////////////////////////////////////////////
#endif // SCENEROOT_H
|
marek-cel/fightersfs-tools
|
terrain_generator/src/gen/Document.h
|
/****************************************************************************//*
* Copyright (C) 2020 <NAME>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
******************************************************************************/
#ifndef DOCUMENT_H
#define DOCUMENT_H
////////////////////////////////////////////////////////////////////////////////
#include <QDomDocument>
#include <QDomElement>
#include <osg/Group>
#include "Terrain.h"
////////////////////////////////////////////////////////////////////////////////
/** */
class Document
{
public:
/** */
Document();
/** */
Document( QString fileName );
/** */
virtual ~Document();
/** */
void newEmpty();
/** */
bool exportAs( QString fileName );
/** */
bool generateElevation( QString fileName );
/** */
bool readFile( QString fileName );
/** */
bool saveFile( QString fileName );
/** */
inline osg::Group* getRootNode()
{
if ( m_terrain )
{
return m_terrain->getRoot();
}
return 0;
}
/** */
inline Terrain* getTerrain()
{
return m_terrain;
}
private:
Terrain *m_terrain;
};
////////////////////////////////////////////////////////////////////////////////
#endif // DOCUMENT_H
|
marek-cel/fightersfs-tools
|
terrain_generator/src/gen/LandCover.h
|
<gh_stars>0
/****************************************************************************//*
* Copyright (C) 2020 <NAME>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
******************************************************************************/
#ifndef LANDCOVER_H
#define LANDCOVER_H
////////////////////////////////////////////////////////////////////////////////
#include "Elevation.h"
#include "Types.h"
////////////////////////////////////////////////////////////////////////////////
/** Land cover. */
class LandCover
{
public:
/** Constructor. */
LandCover();
virtual ~LandCover();
CoverType getType( double lat1, double lon1 ) const;
CoverType getType( double lat1, double lon1,
double lat2, double lon2 ) const;
CoverType getType( double lat1, double lon1,
double lat2, double lon2,
double lat3, double lon3 ) const;
CoverType getType( double lat1, double lon1,
double lat2, double lon2,
double lat3, double lon3,
double lat4, double lon4,
Level level ) const;
bool isCoast( double lat1, double lon1,
double lat2, double lon2,
double lat3, double lon3,
double lat4, double lon4 ) const;
bool isTrees( double lat1, double lon1,
double lat2, double lon2,
double lat3, double lon3,
double lat4, double lon4 ) const;
inline ListGeoTIFF::ListNames getListCrops() const { return m_crops->getList(); }
inline ListGeoTIFF::ListNames getListTrees() const { return m_trees->getList(); }
inline ListGeoTIFF::ListNames getListUrban() const { return m_urban->getList(); }
inline ListGeoTIFF::ListNames getListWater() const { return m_water->getList(); }
inline void setElevation( Elevation *elevation )
{
m_water->setElevation( elevation );
}
inline void setListCrops( const ListGeoTIFF::ListNames &list ) { m_crops->setList( list ); }
inline void setListTrees( const ListGeoTIFF::ListNames &list ) { m_trees->setList( list ); }
inline void setListUrban( const ListGeoTIFF::ListNames &list ) { m_urban->setList( list ); }
inline void setListWater( const ListGeoTIFF::ListNames &list ) { m_water->setList( list ); }
private:
/** Crops. */
class Crops : public ListGeoTIFF
{
public:
/** Constructor. */
Crops();
bool isCrops( double lat1, double lon1 ) const;
bool isCrops( double lat1, double lon1,
double lat2, double lon2 ) const;
bool isCrops( double lat1, double lon1,
double lat2, double lon2,
double lat3, double lon3 ) const;
bool isCrops( double lat1, double lon1,
double lat2, double lon2,
double lat3, double lon3,
double lat4, double lon4 ) const;
};
/** Trees. */
class Trees : public ListGeoTIFF
{
public:
/** Constructor. */
Trees();
bool isTrees( double lat1, double lon1 ) const;
bool isTrees( double lat1, double lon1,
double lat2, double lon2 ) const;
bool isTrees( double lat1, double lon1,
double lat2, double lon2,
double lat3, double lon3 ) const;
bool isTrees( double lat1, double lon1,
double lat2, double lon2,
double lat3, double lon3,
double lat4, double lon4,
Level level ) const;
};
/** Urban. */
class Urban : public ListGeoTIFF
{
public:
/** Constructor. */
Urban();
bool isUrban( double lat1, double lon1 ) const;
bool isUrban( double lat1, double lon1,
double lat2, double lon2 ) const;
bool isUrban( double lat1, double lon1,
double lat2, double lon2,
double lat3, double lon3 ) const;
bool isUrban( double lat1, double lon1,
double lat2, double lon2,
double lat3, double lon3,
double lat4, double lon4 ) const;
};
/** Water. */
class Water : public ListGeoTIFF
{
public:
static const double m_elevMax; ///< [m] max water elevation
/** Constructor. */
Water();
bool isLand( double lat1, double lon1 ) const;
bool isLand( double lat1, double lon1,
double lat2, double lon2 ) const;
bool isLand( double lat1, double lon1,
double lat2, double lon2,
double lat3, double lon3 ) const;
bool isLand( double lat1, double lon1,
double lat2, double lon2,
double lat3, double lon3,
double lat4, double lon4 ) const;
inline void setElevation( Elevation *elevation )
{
m_elevation = elevation;
}
private:
Elevation *m_elevation;
};
Crops *m_crops; ///<
Trees *m_trees; ///<
Urban *m_urban; ///<
Water *m_water; ///<
};
////////////////////////////////////////////////////////////////////////////////
#endif // LANDCOVER_H
|
marek-cel/fightersfs-tools
|
missions_editor/src/editor/Mission.h
|
<filename>missions_editor/src/editor/Mission.h
/****************************************************************************//*
* Copyright (C) 2020 <NAME>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
******************************************************************************/
#ifndef MISSION_H
#define MISSION_H
////////////////////////////////////////////////////////////////////////////////
#include <vector>
#include <QDomDocument>
#include <QDomElement>
#include <editor/Singleton.h>
#include <editor/Route.h>
#include <editor/Stage.h>
#include <editor/Text.h>
#include <editor/Unit.h>
////////////////////////////////////////////////////////////////////////////////
/** Mission class. */
class Mission : public Singleton< Mission >
{
friend class Singleton< Mission >;
public:
typedef std::vector< std::string > ObjectFiles;
typedef std::vector< Route* > Routes;
typedef std::vector< Unit* > Units;
typedef std::vector< Stage* > Stages;
static void saveTextNode( QDomDocument &doc, QDomElement &parentNode,
const std::string &tagName, const std::string &tagValue );
static void saveTextNode( QDomDocument &doc, QDomElement &parentNode,
const std::string &tagName, const Text &tagValue );
private:
/**
* Constructor.
* Using of this constructor is forbidden.
* Instead use static function getInstance() to get Mission object reference.
*/
Mission();
public:
/** Destructor. */
virtual ~Mission();
/** */
void newEmpty();
/** */
bool readFile( QString fileName );
/** */
bool saveFile( QString fileName );
inline bool getTutorial() const { return m_tutorial; }
inline std::string getMissionIcon() const { return m_missionIcon; }
inline std::string getMissionIconLocked() const { return m_missionIconLocked; }
inline std::string getMissionImage() const { return m_missionImage; }
inline std::string getMissionImageLocked() const { return m_missionImageLocked; }
inline Text getMissionName() const { return m_missionName; }
inline Text getMissionIntroduction() const { return m_missionIntroduction; }
inline Text getMissionSummaryFailure() const { return m_missionSummaryFailure; }
inline Text getMissionSummarySuccess() const { return m_missionSummarySuccess; }
inline std::string getElevationFile() const { return m_elevationFile; }
inline std::string getTerrainFile() const { return m_terrainFile; }
inline std::string getGenericFile() const { return m_genericFile; }
inline std::string getSkyDomeFile() const { return m_skyDomeFile; }
inline int getVisibility() const { return m_visibility; }
inline float getSunCoef() const { return m_sunCoef; }
inline ObjectFiles& getObjects() { return m_objectFiles; }
inline Routes& getRoutes() { return m_routes; }
inline Units& getUnits() { return m_units; }
inline Stages& getStages() { return m_stages; }
Unit* getOwnship();
Route* getRouteByName( const std::string &routeName );
int getRouteIndex( const std::string &routeName );
std::string getRouteName( int routeIndex );
int getUnitIndex( const std::string &unitName );
std::string getUnitName( int unitIndex );
inline void setTutorial( bool tutorial ) { m_tutorial = tutorial; }
void setMissionIcon( const std::string &missionIcon );
void setMissionIconLocked( const std::string &missionIconLocked );
void setMissionImage( const std::string &missionImage );
void setMissionImageLocked( const std::string &missionImageLocked );
void setMissionName( const Text &missionName );
void setMissionIntroduction( const Text &missionIntroduction );
void setMissionSummaryFailure( const Text &missionSummaryFailure );
void setMissionSummarySuccess( const Text &missionSummarySuccess );
void setElevationFile( const std::string &elevationFile );
void setTerrainFile( const std::string &terrainFile );
void setGenericFile( const std::string &genericFile );
void setSkyDomeFile( const std::string &skyDomeFile );
void setVisibility( int visibility );
void setSunCoef( float sunCoef );
private:
bool m_tutorial; ///< tutorial mission
std::string m_missionIcon; ///<
std::string m_missionIconLocked; ///<
std::string m_missionImage; ///<
std::string m_missionImageLocked; ///<
Text m_missionName; ///< mission name
Text m_missionIntroduction; ///< mission introduction
Text m_missionSummaryFailure; ///< mission summary failure
Text m_missionSummarySuccess; ///< mission summary success
std::string m_elevationFile; ///< elevation file
std::string m_terrainFile; ///< terrain file
std::string m_genericFile; ///< generic terrain file
ObjectFiles m_objectFiles; ///< object files
std::string m_skyDomeFile; ///< sky dome file
int m_visibility; ///< [m] visibility
float m_sunCoef; ///< [-]
Routes m_routes; ///< routes
Units m_units; ///< units
Stages m_stages; ///< stages
bool readMission( QDomElement &xmlNode );
bool readData( QDomElement &xmlNode );
bool readScenery( QDomElement &xmlNode );
bool readRoutes( QDomElement &xmlNode );
bool readStages( QDomElement &xmlNode );
bool readUnits( QDomElement &xmlNode );
bool readUnits( QDomElement &xmlNode, Unit::Affiliation affiliation,
bool ownship = false );
void saveMission( QDomDocument &doc, QDomElement &parentNode );
void saveData( QDomDocument &doc, QDomElement &parentNode );
void saveScenery( QDomDocument &doc, QDomElement &parentNode );
void saveRoutes( QDomDocument &doc, QDomElement &parentNode );
void saveStages( QDomDocument &doc, QDomElement &parentNode );
void saveUnits( QDomDocument &doc, QDomElement &parentNode );
void saveOwnship( QDomDocument &doc, QDomElement &parentNode );
void saveUnits( QDomDocument &doc, QDomElement &parentNode, Unit::Affiliation affiliation );
};
////////////////////////////////////////////////////////////////////////////////
#endif // MISSION_H
|
marek-cel/fightersfs-tools
|
missions_editor/src/editor/Route.h
|
<reponame>marek-cel/fightersfs-tools<gh_stars>0
/****************************************************************************//*
* Copyright (C) 2020 <NAME>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
******************************************************************************/
#ifndef ROUTE_H
#define ROUTE_H
////////////////////////////////////////////////////////////////////////////////
#include <vector>
#include <string>
#include <osg/Vec3>
////////////////////////////////////////////////////////////////////////////////
typedef std::pair< osg::Vec3, double > Waypoint;
////////////////////////////////////////////////////////////////////////////////
/** Aircraft route class. */
class Route : public std::vector< Waypoint >
{
public:
/** Constructor. */
Route();
/**
* Copy constructor.
* @param route route to copy
*/
Route( const Route &route );
void eraseWaypoint( int waypointIndex );
void insertWaypoint( int waypointIndex, const Waypoint &waypoint );
void decreaseWaypointObjectivesIndeced( int waypointIndex );
void increaseWaypointObjectivesIndeced( int waypointIndex );
void removeFromAllUnits();
void removeWaypointObjectives();
std::string name; ///< route name
};
////////////////////////////////////////////////////////////////////////////////
#endif // ROUTE_H
|
marek-cel/fightersfs-tools
|
missions_editor/src/gui/WidgetDoc.h
|
/****************************************************************************//*
* Copyright (C) 2020 <NAME>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
******************************************************************************/
#ifndef WIDGETDOC_H
#define WIDGETDOC_H
////////////////////////////////////////////////////////////////////////////////
#include <osg/Node>
#include <QWidget>
#include <QListWidgetItem>
#include <editor/Mission.h>
#include <cgi/SceneRoot.h>
////////////////////////////////////////////////////////////////////////////////
namespace Ui
{
class WidgetDoc;
}
////////////////////////////////////////////////////////////////////////////////
/** Document (mission) editing widget class. */
class WidgetDoc : public QWidget
{
Q_OBJECT
public:
/** Constructor. */
explicit WidgetDoc( QWidget *parent = 0 );
/** Destructor. */
~WidgetDoc();
void newEmpty();
bool readFile( QString file );
bool saveFile( QString file );
signals:
void changed();
void sceneryReloaded();
private:
Ui::WidgetDoc *m_ui;
int m_currentObjectIndex;
int m_currentRouteIndex;
int m_currentUnitIndex;
int m_currentStageIndex;
void editObject();
void editRoute();
void editStage();
void editUnit();
void updateGUI();
private slots:
void on_pageRoute_changed();
void on_pageUnit_changed();
void on_pageStage_changed();
void on_pageRoute_done();
void on_pageUnit_done();
void on_pageStage_done();
void on_comboBoxLang_currentIndexChanged(int index);
void on_toolBox_currentChanged(int index);
void on_checkBoxTutorial_toggled(bool checked);
void on_lineEditIcon_textChanged(const QString &arg1);
void on_lineEditIconLocked_textChanged(const QString &arg1);
void on_lineEditImage_textChanged(const QString &arg1);
void on_lineEditImageLocked_textChanged(const QString &arg1);
void on_lineEditName_textChanged(const QString &arg1);
void on_textEditIntroduction_textChanged();
void on_textEditSummaryFailure_textChanged();
void on_textEditSummarySuccess_textChanged();
void on_lineEditTerrain_textChanged(const QString &arg1);
void on_lineEditGeneric_textChanged(const QString &arg1);
void on_lineEditElevation_textChanged(const QString &arg1);
void on_lineEditSkyDome_textChanged(const QString &arg1);
void on_pushButtonTerrain_clicked();
void on_pushButtonGeneric_clicked();
void on_pushButtonElevation_clicked();
void on_pushButtonSkyDome_clicked();
void on_spinBoxVisibility_valueChanged(int arg1);
void on_spinBoxSunCoef_valueChanged(double arg1);
void on_pushButtonObjectAdd_clicked();
void on_pushButtonObjectEdit_clicked();
void on_pushButtonObjectRemove_clicked();
void on_listWidgetObjects_currentRowChanged(int currentRow);
void on_listWidgetObjects_doubleClicked(const QModelIndex &);
void on_pushButtonRouteAdd_clicked();
void on_pushButtonRouteEdit_clicked();
void on_pushButtonRouteRemove_clicked();
void on_listWidgetRoutes_currentRowChanged(int currentRow);
void on_listWidgetRoutes_doubleClicked(const QModelIndex &);
void on_pushButtonUnitAdd_clicked();
void on_pushButtonUnitEdit_clicked();
void on_pushButtonUnitRemove_clicked();
void on_listWidgetUnits_currentRowChanged(int currentRow);
void on_listWidgetUnits_doubleClicked(const QModelIndex &);
void on_pushButtonStageAdd_clicked();
void on_pushButtonStageEdit_clicked();
void on_pushButtonStageRemove_clicked();
void on_listWidgetStages_currentRowChanged(int currentRow);
void on_listWidgetStages_doubleClicked(const QModelIndex &);
};
////////////////////////////////////////////////////////////////////////////////
#endif // WIDGETDOC_H
|
marek-cel/fightersfs-tools
|
missions_editor/src/cgi/VisitorLOD.h
|
/****************************************************************************//*
* Copyright (C) 2020 <NAME>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
******************************************************************************/
#ifndef VISITORLOD_H
#define VISITORLOD_H
////////////////////////////////////////////////////////////////////////////////
#include <string>
#include <vector>
#include <osg/NodeVisitor>
////////////////////////////////////////////////////////////////////////////////
/**
* OpenSceneGraph Level-of-Details visitor class.
* It modifies every LOD node it visits so first child visibility range is set
* to 1.0e6 meters. This is due to the fact that most LODs of terrain. models,
* etc. are limited to achieve better application performance which is not
* practical when used in mission editor. */
class VisitorLOD : public osg::NodeVisitor
{
public:
/** Constructor. */
VisitorLOD( bool first = false );
/** */
virtual void apply( osg::Node &searchNode );
private:
const bool m_first;
};
////////////////////////////////////////////////////////////////////////////////
#endif // VISITORLOD_H
|
marek-cel/fightersfs-tools
|
missions_editor/src/cgi/Camera.h
|
/****************************************************************************//*
* Copyright (C) 2020 <NAME>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
******************************************************************************/
#ifndef CAMERA_H
#define CAMERA_H
////////////////////////////////////////////////////////////////////////////////
#include <cgi/ManipulatorOrbit.h>
#include <cgi/ManipulatorWorld.h>
////////////////////////////////////////////////////////////////////////////////
class SceneRoot;
/** Camera control class. */
class Camera
{
public:
/** Constructor. */
Camera( SceneRoot *sceneRoot );
/** Destructor. */
virtual ~Camera();
/** Updates camera position and attitude. */
void update();
/** */
inline osgGA::CameraManipulator* getManipulator()
{
return m_manipulator.get();
}
inline osg::Vec3d getPosition() { return m_position; }
/** */
inline void setViewOrbit( osg::Node *node )
{
m_manipulator = m_manipulatorOrbit.get();
m_manipulatorOrbit->setTrackNode( node );
m_manipulatorOrbit->setElevation( M_PI_2 );
m_manipulatorOrbit->setHeading( 0.0 );
m_manipulatorOrbit->setDistance( 10000.0 );
}
/** */
inline void setViewWorld( osg::Node *node )
{
m_manipulator = m_manipulatorWorld.get();
m_manipulatorWorld->setNode( node );
m_manipulatorOrbit->setElevation( M_PI_2 );
m_manipulatorOrbit->setHeading( 0.0 );
m_manipulatorOrbit->setDistance( 10000.0 );
}
private:
osg::ref_ptr<osgGA::CameraManipulator> m_manipulator;
osg::ref_ptr<ManipulatorOrbit> m_manipulatorOrbit;
osg::ref_ptr<ManipulatorWorld> m_manipulatorWorld;
osg::Quat m_attitude;
osg::Vec3d m_position;
};
////////////////////////////////////////////////////////////////////////////////
#endif // CAMERA_H
|
marek-cel/fightersfs-tools
|
missions_editor/src/editor/Text.h
|
<reponame>marek-cel/fightersfs-tools
/****************************************************************************//*
* Copyright (C) 2020 <NAME>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
******************************************************************************/
#ifndef TEXT_H
#define TEXT_H
////////////////////////////////////////////////////////////////////////////////
#include <QMap>
#include <QDomElement>
////////////////////////////////////////////////////////////////////////////////
class Text
{
public:
typedef QMap< int, QString > Strings;
/* */
static Text* readText( QDomElement &xmlNode );
/** Default constructor. */
Text();
/** Cppy constructor. */
Text( const Text &text );
/** Destructor. */
virtual ~Text();
Text& operator= ( const Text &text );
/** */
std::string get() const;
/** */
std::string get( int index ) const;
/** */
void set( const char *str );
/** */
void set( const std::string &str );
/** */
void set( const QString &str );
/** */
void set( int index, const char *str );
/** */
void set( int index, const std::string &str );
/** */
void set( int index, const QString &str );
private:
Strings m_strings;
};
////////////////////////////////////////////////////////////////////////////////
#endif // TEXT_H
|
marek-cel/fightersfs-tools
|
missions_editor/src/editor/Stage.h
|
/****************************************************************************//*
* Copyright (C) 2020 <NAME>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
******************************************************************************/
#ifndef STAGE_H
#define STAGE_H
////////////////////////////////////////////////////////////////////////////////
#include <QDomDocument>
#include <QDomElement>
#include <editor/Message.h>
#include <editor/Objective.h>
////////////////////////////////////////////////////////////////////////////////
/** Mission stage class. */
class Stage
{
public:
typedef std::vector< std::string > InitUnits;
typedef std::vector< Objective* > Objectives;
typedef std::vector< Message* > Messages;
/**
* Reads stage from XML file.
* @param xmlNode stage XML node
* @return returns stage object on success and null on failure
*/
static Stage* readStage( QDomElement &xmlNode );
/** Constructor. */
Stage();
/** Destructor. */
virtual ~Stage();
/**
* Saves stage to XML file.
* @param doc XML document
* @param parentNode XML parent node
*/
void saveStage( QDomDocument &doc, QDomElement &parentNode );
std::string getName() const { return m_name; }
float getTimeLimit() const { return m_timeLimit; }
InitUnits& getInitUnits() { return m_initUnits; }
Messages& getMessages() { return m_messages; }
Objectives& getObjectives() { return m_objectives; }
void setName( const std::string &name ) { m_name = name; }
void setTimeLimit( float timeLimit ) { m_timeLimit = timeLimit; }
private:
std::string m_name; ///< stage name
float m_timeLimit; ///< [s] stage time limit
InitUnits m_initUnits; ///< list of units to be inited when stage starts
Messages m_messages; ///< stage messages
Objectives m_objectives; ///< list of stage objectives
};
////////////////////////////////////////////////////////////////////////////////
#endif // STAGE_H
|
marek-cel/fightersfs-tools
|
missions_editor/src/editor/Misc.h
|
<filename>missions_editor/src/editor/Misc.h
/****************************************************************************//*
* Copyright (C) 2020 <NAME>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
******************************************************************************/
#ifndef MISC_H
#define MISC_H
////////////////////////////////////////////////////////////////////////////////
#include <cmath>
#include <math.h>
#include <stddef.h>
#ifdef _MSC_VER
# include <float.h>
#endif
////////////////////////////////////////////////////////////////////////////////
/** @brief Miscellaneous utilities. */
class Misc
{
public:
/**
* @brief Checks if given varaible is Infinite.
* @param val double precision value to test
* @return function returns TRUE if tested value is Infinite
*/
inline static bool isInf( const float &val )
{
# ifdef _MSC_VER
return !( _finite( val ) );
# else
return std::isinf( val );
# endif
}
/**
* @brief Checks if given varaible is NaN.
* @param val double precision value to test
* @return function returns TRUE if tested value is NaN
*/
inline static bool isNaN( const float &val )
{
return ( val != val );
}
/**
* @brief Checks if given varaible is Infinite or NaN.
* @param val double precision value to test
* @return function returns FALSE if tested value is Infinite or NaN
*/
inline static bool isValid( const float &val )
{
return !( isNaN( val ) || isInf( val ) );
}
/**
* @brief Checks if given array is Infinite or NaN.
* @param array double precision array to test
* @param size the size of given array
* @return function returns FALSE if tested array is Infinite or NaN
*/
inline static bool isValid( const float array[], unsigned int size )
{
for ( unsigned int i = 0; i < size; i++ )
{
if ( isNaN( array[ i ] ) || isInf( array[ i ] ) ) return false;
}
return true;
}
};
////////////////////////////////////////////////////////////////////////////////
#endif // MISC_H
|
marek-cel/fightersfs-tools
|
terrain_generator/src/gen/ListGeoTIFF.h
|
/****************************************************************************//*
* Copyright (C) 2020 <NAME>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
******************************************************************************/
#ifndef LISTGEOTIFF_H
#define LISTGEOTIFF_H
////////////////////////////////////////////////////////////////////////////////
#include <string>
#include <vector>
#include "GeoTIFF.h"
////////////////////////////////////////////////////////////////////////////////
class ListGeoTIFF
{
public:
typedef std::vector< std::string > ListNames;
typedef std::vector< GeoTIFF* > ListFiles;
ListGeoTIFF();
virtual ~ListGeoTIFF();
inline ListNames getList() const { return m_listNames; }
short getValue( double lat, double lon, bool nonZero = false ) const;
void setList( const ListNames &list );
protected:
ListNames m_listNames;
ListFiles m_listFiles;
void clearFiles();
};
////////////////////////////////////////////////////////////////////////////////
#endif // LISTGEOTIFF_H
|
marek-cel/fightersfs-tools
|
terrain_generator/src/gui/RecentFileAction.h
|
/****************************************************************************//*
* Copyright (C) 2020 <NAME>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
******************************************************************************/
#ifndef RECENTFILEACTION_H
#define RECENTFILEACTION_H
////////////////////////////////////////////////////////////////////////////////
#include <QAction>
////////////////////////////////////////////////////////////////////////////////
class RecentFileAction : public QAction
{
Q_OBJECT
public:
RecentFileAction( int id, QString text, QObject *parent );
private:
int m_id;
signals:
void triggered( int id );
private slots:
void trigger();
};
////////////////////////////////////////////////////////////////////////////////
#endif // RECENTFILEACTION_H
|
marek-cel/fightersfs-tools
|
terrain_generator/src/gen/Terrain.h
|
/****************************************************************************//*
* Copyright (C) 2020 <NAME>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
******************************************************************************/
#ifndef TERRAIN_H
#define TERRAIN_H
////////////////////////////////////////////////////////////////////////////////
#include <QDomDocument>
#include <QDomElement>
#include <osg/Group>
#include "Geo.h"
#include "Elevation.h"
#include "Exclusion.h"
#include "LandCover.h"
////////////////////////////////////////////////////////////////////////////////
/** */
class Terrain
{
public:
/** */
Terrain();
/** */
Terrain( QDomElement *xmlNode );
/** */
virtual ~Terrain();
/** */
void save( QDomDocument *doc, QDomElement *parentNode );
/** */
void newEmpty();
/** */
void generate();
/** */
bool generateElevation( QString fileName );
/** */
void exportTiles();
inline osg::Group* getRoot() { return m_root.get(); }
inline Geo getGeo() const { return m_geo; }
inline double getOrigLat() const { return m_geo.getOrigLat(); }
inline double getOrigLon() const { return m_geo.getOrigLon(); }
inline unsigned short getTiles() const { return m_tiles; }
inline double getScale() const { return m_geo.getScale(); }
Elevation* getElevation() const { return m_elevation; }
Exclusion* getExclusion() const { return m_exclusion; }
LandCover* getLandCover() const { return m_landCover; }
ListGeoTIFF::ListNames getListElevation() const { return m_elevation->getList(); }
ListGeoTIFF::ListNames getListExclusion() const { return m_exclusion->getList(); }
ListGeoTIFF::ListNames getListLandCrops() const { return m_landCover->getListCrops(); }
ListGeoTIFF::ListNames getListLandTrees() const { return m_landCover->getListTrees(); }
ListGeoTIFF::ListNames getListLandUrban() const { return m_landCover->getListUrban(); }
ListGeoTIFF::ListNames getListLandWater() const { return m_landCover->getListWater(); }
std::vector< std::string > getListDetailed() const { return m_detailed; }
inline void setOrigLat( double origLat ) { m_geo.setOrigLat( origLat ); }
inline void setOrigLon( double origLon ) { m_geo.setOrigLon( origLon ); }
inline void setTiles( unsigned short tiles ) { m_tiles = tiles; }
inline void setScale( double scale ) { m_geo.setScale( scale ); }
inline void setListElevation( const ListGeoTIFF::ListNames &list ) { m_elevation->setList( list ); }
inline void setListExclusion( const ListGeoTIFF::ListNames &list ) { m_exclusion->setList( list ); }
inline void setListLandCrops( const ListGeoTIFF::ListNames &list ) { m_landCover->setListCrops( list ); }
inline void setListLandTrees( const ListGeoTIFF::ListNames &list ) { m_landCover->setListTrees( list ); }
inline void setListLandUrban( const ListGeoTIFF::ListNames &list ) { m_landCover->setListUrban( list ); }
inline void setListLandWater( const ListGeoTIFF::ListNames &list ) { m_landCover->setListWater( list ); }
inline void setListDetailed( const std::vector< std::string > &list ) { m_detailed = list; }
private:
osg::ref_ptr<osg::Group> m_root; ///< terrain root node
Geo m_geo; ///<
unsigned short m_tiles; ///<
Elevation *m_elevation; ///<
Exclusion *m_exclusion; ///<
LandCover *m_landCover; ///<
std::vector< std::string > m_detailed; ///< detailed terrain
osg::Vec3d getPosition( int ix, int iy );
void readListNames( QDomElement *node, std::vector< std::string > &list );
void saveListNames( const std::vector< std::string > &list,
QDomDocument *doc, QDomElement *parentNode );
virtual void saveParameters( QDomDocument *doc, QDomElement *xmlNode );
};
////////////////////////////////////////////////////////////////////////////////
#endif // TERRAIN_H
|
marek-cel/fightersfs-tools
|
terrain_generator/src/gen/GeoTIFF.h
|
/****************************************************************************//*
* Copyright (C) 2020 <NAME>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
******************************************************************************/
#ifndef GEOTIFF_H
#define GEOTIFF_H
////////////////////////////////////////////////////////////////////////////////
#include <gdal/gdal.h>
////////////////////////////////////////////////////////////////////////////////
class GeoTIFF
{
public:
GeoTIFF( const char *file = 0 );
virtual ~GeoTIFF();
void getGeo( int x, int y, double &lat, double &lon ) const;
void getImg( double lat, double lon, int &x, int &y ) const;
bool inRange( double lat, double lon ) const;
short getValue( double lat, double lon ) const;
protected:
GDALDatasetH m_hDataset; ///<
int m_raster_w; ///< [pt]
int m_raster_h; ///< [pt]
double m_ul_lat; ///< [rad]
double m_ul_lon; ///< [rad]
double m_lr_lat; ///< [rad]
double m_lr_lon; ///< [rad]
double m_pt_rad_x; ///< [pt/rad]
double m_pt_rad_y; ///< [pt/rad]
};
////////////////////////////////////////////////////////////////////////////////
#endif // GEOTIFF_H
|
marek-cel/fightersfs-tools
|
missions_editor/src/gui/DialogEditObjectiveDestroy.h
|
<reponame>marek-cel/fightersfs-tools<filename>missions_editor/src/gui/DialogEditObjectiveDestroy.h
/****************************************************************************//*
* Copyright (C) 2020 <NAME>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
******************************************************************************/
#ifndef DIALOGEDITOBJECTIVEDESTROY_H
#define DIALOGEDITOBJECTIVEDESTROY_H
////////////////////////////////////////////////////////////////////////////////
#include <QDialog>
#include <editor/Mission.h>
#include <editor/ObjectiveDestroy.h>
////////////////////////////////////////////////////////////////////////////////
namespace Ui
{
class DialogEditObjectiveDestroy;
}
////////////////////////////////////////////////////////////////////////////////
/** Destroy objective editing dialog class. */
class DialogEditObjectiveDestroy : public QDialog
{
Q_OBJECT
public:
/** Constructor. */
explicit DialogEditObjectiveDestroy( QWidget *parent = 0 );
/** Destructor. */
~DialogEditObjectiveDestroy();
void setObj( ObjectiveDestroy *obj );
public slots:
void accept();
private:
Ui::DialogEditObjectiveDestroy *m_ui;
ObjectiveDestroy *m_obj;
int m_currentUnitIndex;
ObjectiveDestroy::Units m_units;
private slots:
void on_pushButtonDestroyUnitAdd_clicked();
void on_pushButtonDestroyUnitRemove_clicked();
void on_listWidgetDestroyUnits_currentRowChanged(int currentRow);
};
////////////////////////////////////////////////////////////////////////////////
#endif // DIALOGEDITOBJECTIVEDESTROY_H
|
marek-cel/fightersfs-tools
|
terrain_generator/src/gen/Common.h
|
/****************************************************************************//*
* Copyright (C) 2020 <NAME>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
******************************************************************************/
#ifndef COMMON_H
#define COMMON_H
////////////////////////////////////////////////////////////////////////////////
#include <string>
#include <osg/Geode>
#include <osg/Material>
#include <osg/StateSet>
#include "Singleton.h"
#include "Types.h"
////////////////////////////////////////////////////////////////////////////////
/** Common. */
class Common : public Singleton< Common >
{
friend class Singleton< Common >;
public:
static const double horizon; ///< [m] distance to the horizon
static const double stepH; ///< [m] step size (high details)
static const double stepM; ///< [m] step size (medium details)
static const double stepL; ///< [m] step size (low details)
static const double texS; ///< [m] small texture size
static const double texL; ///< [m] large texture size
static const double tileH; ///< [m] tile size (high details)
static const double tileM; ///< [m] tile size (medium details)
static const double tileL; ///< [m] tile size (low details)
static const double block; ///< [m] size of low details tiles blosk
static const double radiusH; ///< [m] tile radius (high details)
static const double radiusM; ///< [m] tile radius (medium details)
static const double radiusL; ///< [m] tile radius (low details)
static const double radiusB; ///< [m] block radius
static const float maxAnisotropy; ///<
static const std::string texturesDir;
static const std::string coverTextures[ TILE_MAX_COVER_TYPES ];
static const std::string coastTexturesSquares[ TILE_MAX_COAST_SQUARES_TYPES ];
static const std::string coastTexturesRows[ TILE_MAX_COAST_ROWS_TYPES ];
static const std::string coastTexturesCols[ TILE_MAX_COAST_COLS_TYPES ];
static const std::string treesTexturesSquares[ TILE_MAX_TREES_SQUARES_TYPES ];
static const std::string treesTexturesRows[ TILE_MAX_TREES_ROWS_TYPES ];
static const std::string treesTexturesCols[ TILE_MAX_TREES_COLS_TYPES ];
private:
/**
* You should use static function getInstance() due to get refernce
* to Common class instance.
*/
Common();
/** Using this constructor is forbidden. */
Common( const Common & ) {}
public:
void init();
inline osg::Material* getMaterial() { return m_material.get(); }
inline osg::Geode* getOcean( Level level )
{
if ( level == LevelH )
return m_oceanH.get();
else if ( level == LevelM )
return m_oceanM.get();
return m_oceanL.get();
}
inline osg::StateSet* getCoverStateSet( CoverType i, Level j )
{
return m_stateCover[ i ][ j ].get();
}
inline osg::StateSet* getCoastStateSetSquares( unsigned int i, unsigned int j )
{
return m_stateCoastSquares[ i ][ j ].get();
}
inline osg::StateSet* getCoastStateSetRows( unsigned int i, unsigned int j )
{
return m_stateCoastRows[ i ][ j ].get();
}
inline osg::StateSet* getCoastStateSetCols( unsigned int i, unsigned int j )
{
return m_stateCoastCols[ i ][ j ].get();
}
inline osg::StateSet* getTreesStateSetSquares( unsigned int i, unsigned int j )
{
return m_stateTreesSquares[ i ][ j ].get();
}
inline osg::StateSet* getTreesStateSetRows( unsigned int i, unsigned int j )
{
return m_stateTreesRows[ i ][ j ].get();
}
inline osg::StateSet* getTreesStateSetCols( unsigned int i, unsigned int j )
{
return m_stateTreesCols[ i ][ j ].get();
}
inline bool isOceanValid( Level level )
{
if ( level == LevelH )
return m_oceanH.valid();
else if ( level == LevelM )
return m_oceanM.valid();
return m_oceanL.valid();
}
inline void setOcean( Level level, osg::Geode *ocean )
{
if ( level == LevelH )
{
m_oceanH = ocean;
osg::notify(osg::ALWAYS) << "Ocean H set." << std::endl;
}
else if ( level == LevelM )
{
m_oceanM = ocean;
osg::notify(osg::ALWAYS) << "Ocean M set." << std::endl;
}
else if ( level == LevelL )
{
m_oceanL = ocean;
osg::notify(osg::ALWAYS) << "Ocean L set." << std::endl;
}
}
private:
bool m_inited;
osg::ref_ptr<osg::Geode> m_oceanH; ///<
osg::ref_ptr<osg::Geode> m_oceanM; ///<
osg::ref_ptr<osg::Geode> m_oceanL; ///<
osg::ref_ptr<osg::Material> m_material; ///<
osg::ref_ptr<osg::StateSet> m_stateCover[ TILE_MAX_COVER_TYPES ][ TILE_MAX_LEVELS ];
osg::ref_ptr<osg::StateSet> m_stateCoastSquares[ TILE_MAX_COAST_SQUARES_TYPES ][ 64 ];
osg::ref_ptr<osg::StateSet> m_stateCoastRows[ TILE_MAX_COAST_ROWS_TYPES ][ 8 ];
osg::ref_ptr<osg::StateSet> m_stateCoastCols[ TILE_MAX_COAST_COLS_TYPES ][ 8 ];
osg::ref_ptr<osg::StateSet> m_stateTreesSquares[ TILE_MAX_TREES_SQUARES_TYPES ][ 64 ];
osg::ref_ptr<osg::StateSet> m_stateTreesRows[ TILE_MAX_TREES_ROWS_TYPES ][ 8 ];
osg::ref_ptr<osg::StateSet> m_stateTreesCols[ TILE_MAX_TREES_COLS_TYPES ][ 8 ];
std::string getCoverTexture( CoverType type, Level level );
std::string getCoastTextureSquares( CoastTypeSquares type, int tile );
std::string getCoastTextureRows( CoastTypeRows type, int tile );
std::string getCoastTextureCols( CoastTypeCols type, int tile );
std::string getTreesTextureSquares( TreesTypeSquares type, int tile );
std::string getTreesTextureRows( TreesTypeRows type, int tile );
std::string getTreesTextureCols( TreesTypeCols type, int tile );
};
////////////////////////////////////////////////////////////////////////////////
#endif // COMMON_H
|
marek-cel/fightersfs-tools
|
terrain_generator/src/defs.h
|
#ifndef DEFS_H
#define DEFS_H
////////////////////////////////////////////////////////////////////////////////
#define APP_TITLE "FightersFS Terrain Generator"
#define APP_NAME "FightersFS_Terrain_Generator"
#define APP_VER "1.0"
#define ORG_NAME "Marek_Cel"
#define ORG_DOMAIN "marekcel.pl"
////////////////////////////////////////////////////////////////////////////////
#endif // DEFS_H
|
marek-cel/fightersfs-tools
|
terrain_generator/src/gen/Tile.h
|
<reponame>marek-cel/fightersfs-tools<filename>terrain_generator/src/gen/Tile.h
/****************************************************************************//*
* Copyright (C) 2020 <NAME>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom
* the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
******************************************************************************/
#ifndef TILE_H
#define TILE_H
////////////////////////////////////////////////////////////////////////////////
#include <osg/Array>
#include <osg/Geode>
#include <osg/Geometry>
#include <osg/LOD>
#include "Common.h"
#include "Terrain.h"
////////////////////////////////////////////////////////////////////////////////
/** */
class Tile
{
public:
struct VTN
{
osg::ref_ptr<osg::Vec3Array> v;
osg::ref_ptr<osg::Vec2Array> t;
osg::ref_ptr<osg::Vec3Array> n;
};
struct Data
{
VTN vtn;
osg::ref_ptr<osg::Geometry> geometry;
};
static const bool m_zeroizeElevation;
/** Constructor. */
Tile( Level level );
/** Constructor. */
Tile( Terrain *terrain, double x0, double y0, Level level, Tile *parent = 0, bool lod = true );
double getAbsX0() const;
double getAbsY0() const;
inline double getAbsX( double x ) const { return getAbsX0() + x; }
inline double getAbsY( double y ) const { return getAbsY0() + y; }
inline osg::Group* getRoot() { return m_root.get(); }
private:
const bool m_ocean;
const double m_x0; ///< [m] tile origin x-coordinate relative to the parent origin
const double m_y0; ///< [m] tile origin y-coordinate relative to the parent origin
const Level m_level; ///< details level (0: highest details)
const bool m_lod; ///<
Terrain *m_terrain; ///<
Tile *m_parent; ///< parent tile
double m_step; ///< [m] step
double m_size; ///< [m] size
double m_radius; ///<
double m_offset; ///< [m]
double m_range0; ///< [m]
double m_range1; ///< [m]
double m_range2; ///< [m]
unsigned short m_steps; ///< number of steps per tile
osg::ref_ptr<osg::Group> m_root; ///<
osg::ref_ptr<osg::LOD> m_rootLOD;
bool m_ground; ///< specifies if tile is ground
Data m_cover[ TILE_MAX_COVER_TYPES ];
Data m_coastSquares[ TILE_MAX_COAST_SQUARES_TYPES ][ 64 ];
Data m_coastRows[ TILE_MAX_COAST_ROWS_TYPES ][ 8 ];
Data m_coastCols[ TILE_MAX_COAST_COLS_TYPES ][ 8 ];
Data m_treesSquares[ TILE_MAX_TREES_SQUARES_TYPES ][ 64 ];
Data m_treesRows[ TILE_MAX_TREES_ROWS_TYPES ][ 8 ];
Data m_treesCols[ TILE_MAX_TREES_COLS_TYPES ][ 8 ];
void init();
void createData();
void createData( Data &data, osg::StateSet *stateSet );
void generate();
void createSquare( int jx, int jy );
void createBorderS( int jx, int jy );
void createBorderN( int jx, int jy );
void createBorderW( int jx, int jy );
void createBorderE( int jx, int jy );
void createBorder( VTN &vtn,
osg::Vec3d &r1,
osg::Vec3d &r2,
osg::Vec3d &r3,
osg::Vec3d &r4 );
void createCover( bool even,
double lat1, double lon1,
double lat2, double lon2,
double lat3, double lon3,
double lat4, double lon4,
const osg::Vec3d &r1,
const osg::Vec3d &r2,
const osg::Vec3d &r3,
const osg::Vec3d &r4 );
void createCoast( bool even,
double lat1, double lon1,
double lat2, double lon2,
double lat3, double lon3,
double lat4, double lon4,
const osg::Vec3d &r1,
const osg::Vec3d &r2,
const osg::Vec3d &r3,
const osg::Vec3d &r4,
int jx, int jy );
void createTrees( bool even,
double lat1, double lon1,
double lat2, double lon2,
double lat3, double lon3,
double lat4, double lon4,
const osg::Vec3d &r1,
const osg::Vec3d &r2,
const osg::Vec3d &r3,
const osg::Vec3d &r4,
int jx, int jy );
void createSquare( bool even,
VTN &vtn1, VTN &vtn2,
const osg::Vec3d &r1,
const osg::Vec3d &r2,
const osg::Vec3d &r3,
const osg::Vec3d &r4,
double texX, double texY );
/** even */
void createTriangle1E( VTN &vtn,
const osg::Vec3d &r1,
const osg::Vec3d &r2,
const osg::Vec3d &r3,
double texX, double texY );
/** odd */
void createTriangle1O( VTN &vtn,
const osg::Vec3d &r1,
const osg::Vec3d &r2,
const osg::Vec3d &r4,
double texX, double texY );
/** even */
void createTriangle2E( VTN &vtn,
const osg::Vec3d &r2,
const osg::Vec3d &r3,
const osg::Vec3d &r4,
double texX, double texY );
/** odd */
void createTriangle2O( VTN &vtn,
const osg::Vec3d &r1,
const osg::Vec3d &r3,
const osg::Vec3d &r4,
double texX, double texY );
osg::Vec3d getNormal( const osg::Vec3d &r );
double getTexCoord( double val, double textureSize );
void createGeom();
template <size_t i_max, size_t j_max>
void createGeom( Data data[i_max][j_max] )
{
for ( size_t i = 0; i < i_max; i++ )
{
for ( size_t j = 0; j < j_max; j++ )
{
createGeom( data[ i ][ j ] );
}
}
}
void createGeom( Data &data );
void addToGeode();
template <size_t i_max, size_t j_max>
void addToGeode( osg::Geode *geode, Data data[i_max][j_max] )
{
for ( size_t i = 0; i < i_max; i++ )
{
for ( size_t j = 0; j < j_max; j++ )
{
if ( data[ i ][ j ].vtn.v->size() > 0 )
{
geode->addDrawable( data[ i ][ j ].geometry.get() );
}
}
}
}
void generateSubtiles();
};
////////////////////////////////////////////////////////////////////////////////
#endif // TILE_H
|
hellochenms/m4-scroll-half-stop
|
m4-scroll-half-stop/m2/M4Status3ScrollViewHelper.h
|
<reponame>hellochenms/m4-scroll-half-stop<filename>m4-scroll-half-stop/m2/M4Status3ScrollViewHelper.h
//
// M4Status3ScrollViewHelper.h
// m4-scroll-half-stop
//
// Created by Chen,Meisong on 2018/10/23.
// Copyright © 2018年 xyz.chenms. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface M4Status3ScrollViewHelper : NSObject
@property (nonatomic) CGFloat naviBarTriggerY;
@property (nonatomic) CGFloat neckY;
@property (nonatomic) CGFloat ankleY;
- (UIEdgeInsets)contentInset;
- (CGPoint)startOffset;
- (CGPoint)targetPointWithScrollView:(UIScrollView *)scrollView
velocity:(CGPoint)velocity
shouldUse:(BOOL *)shouldUse;
- (BOOL)bouncesWithScrollView:(UIScrollView *)scrollView;
- (CGFloat)naviBarProgressWithScrollView:(UIScrollView *)scrollView;
@end
NS_ASSUME_NONNULL_END
|
hellochenms/m4-scroll-half-stop
|
m4-scroll-half-stop/m2/M4TouchPenetrateScrollView.h
|
<reponame>hellochenms/m4-scroll-half-stop
//
// M4TouchPenetrateScrollView.h
// m4-scroll-half-stop
//
// Created by Chen,Meisong on 2018/10/23.
// Copyright © 2018年 xyz.chenms. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface M4TouchPenetrateScrollView : UITableView
@end
NS_ASSUME_NONNULL_END
|
ashuping/m328pb_sound_processing
|
goertzel.c
|
<gh_stars>0
/* ATMega238pb sound processing experiments - Goertzel algorithm and related operations
Copyright 2019 <NAME>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "goertzel.h"
#include "sampling.h"
volatile float target_freq_magnitude_squared;
volatile uint8_t goertzel_ready;
volatile float q0;
volatile float q1;
volatile float q2;
void goertzel_per_sample(){
if(g_adc_val_buf_cur == 0){
q1 = 0.0;
q2 = 0.0;
}
q0 = GOERTZEL_COEFF*q1 - q2 + g_adc_val_buf[g_adc_val_buf_cur];
q2 = q1;
q1 = q0;
}
void goertzel_end_of_block(){
target_freq_magnitude_squared = (q1*q1 + q2*q2 - q1*q2*GOERTZEL_COEFF)/GOERTZEL_SCALING_COEFF;
goertzel_ready = 1;
}
|
ashuping/m328pb_sound_processing
|
project.c
|
<filename>project.c
/* ATMega238pb sound processing experiments - main file
Copyright 2019 <NAME>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef F_CPU
#define F_CPU 8000000UL
#endif
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include <stdio.h>
#include "common.h"
#include "sampling.h"
#include "goertzel.h"
#include "usart.h"
#include "leds.h"
int main(void){
setup_sampling();
setup_led_timer();
setup_tone();
start_sampling();
SET_LED_DUTY_CYCLE(0);
start_pwm();
goertzel_ready = 0;
sei();
uint8_t values[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
uint8_t values_index = 0;
while(1){
if(goertzel_ready){
values[values_index] = (uint8_t)target_freq_magnitude_squared;
values_index = values_index == 15 ? 0 : values_index+1;
uint16_t sum = 0;
for(uint8_t i = 0; i < 16; ++i){
sum += values[i];
}
uint8_t sum_capped = sum > 255 ? 255 : (uint8_t)sum;
if(sum_capped == 0){
stop_pwm();
}else{
if(sum_capped > 50){
start_tone();
}else{
stop_tone();
}
start_pwm();
SET_LED_DUTY_CYCLE(sum_capped);
}
char str[50];
sprintf(str, "%i", sum_capped);
/*cli();
println(str);
sei();*/
goertzel_ready = 0;
}
}
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.