Skip to content

Commit

Permalink
Merge pull request #2 from stopgaming/fork2
Browse files Browse the repository at this point in the history
window-resize e1
  • Loading branch information
stopgaming authored Aug 23, 2023
2 parents f67e163 + f11a5ed commit 6877ad7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
26 changes: 17 additions & 9 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,22 @@ extern "C" uint8_t _binary_MontserratMedium_nRxlJ_ttf_end[];

int main()
{
sf::RenderWindow window(sf::VideoMode(800, 800), "SFML works!");
sf::RenderWindow window(sf::VideoMode(800, 800), "Hanjie Japan Nonogram");
window.setVerticalSyncEnabled(true);
window.setFramerateLimit(60);
sf::RectangleShape shape(sf::Vector2f(70.f, 70.f));

sf::Font font;
// if (!font.loadFromFile("MontserratMedium_nRxlJ.ttf "))
if (!font.loadFromMemory(_binary_MontserratMedium_nRxlJ_ttf_start,_binary_MontserratMedium_nRxlJ_ttf_end - _binary_MontserratMedium_nRxlJ_ttf_start))
if (!font.loadFromMemory(_binary_MontserratMedium_nRxlJ_ttf_start,_binary_MontserratMedium_nRxlJ_ttf_end - _binary_MontserratMedium_nRxlJ_ttf_start))
{
std::cout << "error";
}


float size = 70.f;

vector<vector<int>> image =
vector<vector<int>> image =
{
{0, 0, 0, 1, 0, 0, 1},
{0, 0, 1, 1, 1, 0, 0},
Expand Down Expand Up @@ -62,20 +64,26 @@ if (!font.loadFromMemory(_binary_MontserratMedium_nRxlJ_ttf_start,_binary_Montse
if (event.type == sf::Event::Closed)
window.close();

if (event.type == sf::Event::MouseButtonPressed)
if(event.type == sf::Event::Resized)
{
if (event.mouseButton.button == sf::Mouse::Left)
sf::FloatRect view(0, 0, event.size.width, event.size.height);
window.setView(sf::View(view));
}

if (event.type == sf::Event::MouseButtonPressed)
{
if (event.mouseButton.button == sf::Mouse::Left)
{
sf::Vector2i localPosition = sf::Mouse::getPosition(window);
if (
(localPosition.x < size * cols + hint_rows * size)
(localPosition.x < size * cols + hint_rows * size)
&& (localPosition.y < size * rows + hint_cols * size)
&& (localPosition.x > hint_rows * size)
&& (localPosition.y > hint_cols * size)
)
)
{
int index = ((localPosition.x - hint_rows * int(size)) / static_cast<int>(size))
+ ((localPosition.y - hint_cols * int(size)) / static_cast<int>(size)) * cols;
int index = ((localPosition.x - hint_rows * int(size)) / static_cast<int>(size))
+ ((localPosition.y - hint_cols * int(size)) / static_cast<int>(size)) * cols;

sf::Color color = arr[index].getFillColor();
if (color == sf::Color::White) {
Expand Down
6 changes: 5 additions & 1 deletion make_in_mingw.bat
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ pkg-config --libs --static sfml-all >> libsflags.tmp
@echo -static -static-libgcc -static-libstdc++ >> libsflags.tmp
fix_msys2.exe


astyle main.cpp
del main.cpp.orig
objcopy --prefix-symbol=_ --input-target binary --output-target pe-i386 --binary-architecture i386 MontserratMedium_nRxlJ.ttf font1.o
g++ -o3 @cflags.tmp -c main.cpp -o main.o
g++ main.o font1.o @libsflags.tmp @libsflags.tmp -o Japan.exe

del fix_msys2.exe
del cflags.tmp
del libsflags.tmp
del *.o

0 comments on commit 6877ad7

Please sign in to comment.