// File: /workspace/github_cpp_makefile_star2_O1/Stygain[P]bandwidth-monitor/src/settingsWindow.cpp
// Function: SettingsWindow::Selected()
SettingsWindowSelection SettingsWindow::Selected()
{
	if (this->activeItem != -1)
	{
		if (this->activeItem < settings->root["hiddenInterfaces"].size())
		{
			// Unhide this interface
			logger->Log("Selected interface: ");
			logger->Log(settings->root["hiddenInterfaces"][this->activeItem].asString());
			logger->Log("\n");

			Interface *toUnhide = getMatchingInterface(settings->root["hiddenInterfaces"][this->activeItem].asString().c_str());

			Json::Value newArr;
			for (int i = 0; i < settings->root["hiddenInterfaces"].size(); i++)
			{
				if (i != this->activeItem)
				{
					newArr.append(settings->root["hiddenInterfaces"][i].asString());
				}
			}
			settings->root["hiddenInterfaces"] = newArr;
			settings->SaveSettings();
			
			// Resize window
			this->activeItem = -1;
			this->Resize(this->placementX, this->placementY, this->width);
			this->Update();

			extern std::vector<InterfaceRow *> interfaceRows;
			extern std::vector<Interface *> interfaces;

			InterfaceRow *interfaceRow = new InterfaceRow(0, (interfaceRows.size() * 3) + 1, COLS, 3);
			interfaceRows.push_back(interfaceRow);
			toUnhide->AddToUI();
			toUnhide->setInterfaceRow(interfaceRow);

			// Return a value so that in main we create an interface row for the unhidden interface
			return CREATE_NEW_INTERFACE;
		}
		else if (this->activeItem == settings->root["hiddenInterfaces"].size())
		{
			settings->root["zeroOnStart"] = settings->root["zeroOnStart"] == 0 ? 1 : 0;
			settings->SaveSettings();

			this->Update();
		}
	}

	return NO_ACTION;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movl 0x1c(%rdi), %r14d
movl $0x1, %ebp
cmpl $-0x1, %r14d
je 0xb5ea
movq %rdi, %rbx
leaq 0x509e(%rip), %r15      # 0x10390
movq (%r15), %rdi
leaq 0xe72(%rip), %rsi       # 0xc16e
callq 0x3130
movq %rax, %rdi
callq 0x34e0
cmpl %eax, %r14d
jae 0xb47e
leaq 0x5067(%rip), %r13      # 0x10380
movq (%r13), %rdi
leaq 0x165a(%rip), %rsi      # 0xc97e
callq 0xa5cc
movq (%r13), %r14
movq (%r15), %rdi
leaq 0xe37(%rip), %rsi       # 0xc16e
callq 0x3130
movl 0x1c(%rbx), %esi
movq %rax, %rdi
callq 0x3300
leaq 0x78(%rsp), %r12
movq %r12, %rdi
movq %rax, %rsi
callq 0x3580
movq %r14, %rdi
movq %r12, %rsi
callq 0xa61a
leaq 0x88(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb383
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x32d0
movq (%r13), %rdi
leaq 0xf25(%rip), %rsi       # 0xc2b3
callq 0xa5cc
movq (%r15), %rdi
leaq 0xdd1(%rip), %rsi       # 0xc16e
callq 0x3130
movl 0x1c(%rbx), %esi
movq %rax, %rdi
callq 0x3300
movq %rsp, %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x3580
movq (%r14), %rdi
callq 0xa3f3
movq %rax, 0x28(%rsp)
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb3e3
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x32d0
movq %rsp, %rdi
xorl %ebp, %ebp
xorl %esi, %esi
callq 0x3160
leaq 0xd78(%rip), %r12       # 0xc16e
leaq 0x30(%rsp), %r13
leaq 0x50(%rsp), %r14
movq (%r15), %rdi
movq %r12, %rsi
callq 0x3130
movq %rax, %rdi
callq 0x34e0
cmpl %eax, %ebp
jae 0xb51d
cmpl 0x1c(%rbx), %ebp
je 0xb47a
movq (%r15), %rdi
movq %r12, %rsi
callq 0x3130
movq %rax, %rdi
movl %ebp, %esi
callq 0x3300
movq %r13, %rdi
movq %rax, %rsi
callq 0x3580
movq %r14, %rdi
movq %r13, %rsi
callq 0x34c0
movq %rsp, %rdi
movq %r14, %rsi
callq 0x33e0
movq %r14, %rdi
callq 0x31b0
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0xb47a
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x32d0
incl %ebp
jmp 0xb400
movl 0x1c(%rbx), %r14d
movq (%r15), %rdi
leaq 0xce2(%rip), %rsi       # 0xc16e
callq 0x3130
movq %rax, %rdi
callq 0x34e0
cmpl %eax, %r14d
jne 0xb5ea
movq (%r15), %rdi
leaq 0xe44(%rip), %rsi       # 0xc2f0
callq 0x3130
movq %rax, %r14
leaq 0x50(%rsp), %r12
movq %r12, %rdi
xorl %esi, %esi
callq 0x3200
movq %r14, %rdi
movq %r12, %rsi
callq 0x33d0
movzbl %al, %esi
movq %rsp, %rdi
callq 0x3200
movq (%r15), %rdi
leaq 0xe0d(%rip), %rsi       # 0xc2f0
callq 0x3130
movq %rsp, %r14
movq %rax, %rdi
movq %r14, %rsi
callq 0x3380
movq %r14, %rdi
callq 0x31b0
leaq 0x50(%rsp), %rdi
callq 0x31b0
movq (%r15), %rdi
callq 0xa928
movq %rbx, %rdi
callq 0xaf88
jmp 0xb5ea
movq (%r15), %rdi
leaq 0xc47(%rip), %rsi       # 0xc16e
callq 0x3130
movq %rsp, %rsi
movq %rax, %rdi
callq 0x3410
movq (%r15), %rdi
callq 0xa928
movl $0xffffffff, 0x1c(%rbx) # imm = 0xFFFFFFFF
movl 0x8(%rbx), %esi
movl 0xc(%rbx), %edx
movl 0x10(%rbx), %ecx
movq %rbx, %rdi
callq 0xb20c
movq %rbx, %rdi
callq 0xaf88
movl $0x18, %edi
callq 0x32c0
movq 0x28(%rsp), %r15
movq %rax, %r14
leaq 0x4d98(%rip), %rbx      # 0x10310
movq 0x8(%rbx), %rax
subq (%rbx), %rax
shrq $0x3, %rax
leal (%rax,%rax,2), %edx
incl %edx
movq 0x4a29(%rip), %rax      # 0xffb8
movl (%rax), %ecx
movq %r14, %rdi
xorl %esi, %esi
movl $0x3, %r8d
callq 0x963e
movq %r14, 0x50(%rsp)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0xb5ba
movq %r14, (%rsi)
addq $0x8, 0x8(%rbx)
jmp 0xb5cb
leaq 0x4d4f(%rip), %rdi      # 0x10310
leaq 0x50(%rsp), %rdx
callq 0x7db4
movq %r15, %rdi
callq 0xa042
movq 0x50(%rsp), %rsi
movq %r15, %rdi
callq 0xa02a
movq %rsp, %rdi
callq 0x31b0
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq %rsp, %rdi
callq 0x31b0
jmp 0xb633
movq %rax, %rbx
movl $0x18, %esi
movq %r14, %rdi
jmp 0xb68d
movq %rax, %rbx
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb6a1
movq 0x10(%rsp), %rsi
jmp 0xb656
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
jmp 0xb69c
movq %rax, %rbx
leaq 0x88(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb6a1
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x32d0
jmp 0xb6a1
jmp 0xb696
jmp 0xb696
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x31b0
jmp 0xb676
movq %rax, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0xb699
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x32d0
jmp 0xb699
jmp 0xb696
movq %rax, %rbx
movq %rsp, %rdi
callq 0x31b0
movq %rbx, %rdi
callq 0x3550